2012-05-11 20 views
1

Javaで書かれたWebサービスを呼び出すためにWCF .Net 4.0を使用しています。 WSDLの一部はSPML 2.0を参照していますが、何が起こったのかを記述するためのコードを付けました。WCF 4.0 Java WebサービスからSOAPを逆シリアル化できない

いくつかのXSDへのWSDLの参照、私が使用しています作品は、だから、WCFサービス参照生成されたプロキシクラスが

[System.Xml.Serialization.XmlIncludeAttribute(typeof(SchemaType1))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ObjectClassDefinitionType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ObjectClassDefinitionReferencesType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ObjectClassDefinitionReferenceType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AttributeDefinitionReferencesType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AttributeDefinitionReferenceType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AttributeDefinitionType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CapabilityType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CapabilitiesListType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SchemaEntityRefType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SchemaType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(TargetType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(PSOType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ActiveResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SearchResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ValidatePasswordResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResetPasswordResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BatchResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ListTargetsResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(LookupResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ModifyResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AddResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuthenticateUserResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SuggestUserIDResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResultsIteratorType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SearchQueryType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(NamespacePrefixMappingType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(QueryClauseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(IsActiveType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(LogicalOperatorType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SelectionType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ModificationType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(IdentifierType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(PSOIdentifierType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(RequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ActiveRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResumeRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SuspendRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CloseIteratorRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(IterateRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SearchRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ValidatePasswordRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResetPasswordRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ExpirePasswordRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SetPasswordRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BatchRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ListTargetsRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(LookupRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(DeleteRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ModifyRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AddRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuthenticateUserRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SuggestUserIDRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(VerifySecurityAnswerRequestType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CapabilityDataType))] 
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")] 
[System.SerializableAttribute()] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:oasis:names:tc:SPML:2:0")] 
public partial class ExtensibleType : object, System.ComponentModel.INotifyPropertyChanged { 

    private System.Xml.XmlElement[] anyField; 

    private System.Xml.XmlAttribute[] anyAttrField; 

    /// <remarks/> 
    [System.Xml.Serialization.XmlAnyElementAttribute(Order=0)] 
    public System.Xml.XmlElement[] Any { 
     get { 
      return this.anyField; 
     } 
     set { 
      this.anyField = value; 
      this.RaisePropertyChanged("Any"); 
     } 
    } 

    /// <remarks/> 
    [System.Xml.Serialization.XmlAnyAttributeAttribute()] 
    public System.Xml.XmlAttribute[] AnyAttr { 
     get { 
      return this.anyAttrField; 
     } 
     set { 
      this.anyAttrField = value; 
      this.RaisePropertyChanged("AnyAttr"); 
     } 
    } 

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; 

    protected void RaisePropertyChanged(string propertyName) { 
     System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; 
     if ((propertyChanged != null)) { 
      propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); 
     } 
    } 
} 

[System.Xml.Serialization.XmlIncludeAttribute(typeof(ActiveResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SearchResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ValidatePasswordResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResetPasswordResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(BatchResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ListTargetsResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(LookupResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ModifyResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AddResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(AuthenticateUserResponseType))] 
[System.Xml.Serialization.XmlIncludeAttribute(typeof(SuggestUserIDResponseType))] 
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")] 
[System.SerializableAttribute()] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:oasis:names:tc:SPML:2:0")] 
public partial class ResponseType : ExtensibleType { 

    private string[] errorMessageField; 

    private StatusCodeType statusField; 

    private string requestIDField; 

    private ErrorCode errorField; 

    private bool errorFieldSpecified; 

    /// <remarks/> 
    [System.Xml.Serialization.XmlElementAttribute("errorMessage", Order=0)] 
    public string[] errorMessage { 
     get { 
      return this.errorMessageField; 
     } 
     set { 
      this.errorMessageField = value; 
      this.RaisePropertyChanged("errorMessage"); 
     } 
    } 

    /// <remarks/> 
    [System.Xml.Serialization.XmlAttributeAttribute()] 
    public StatusCodeType status { 
     get { 
      return this.statusField; 
     } 
     set { 
      this.statusField = value; 
      this.RaisePropertyChanged("status"); 
     } 
    } 

    /// <remarks/> 
    [System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")] 
    public string requestID { 
     get { 
      return this.requestIDField; 
     } 
     set { 
      this.requestIDField = value; 
      this.RaisePropertyChanged("requestID"); 
     } 
    } 

    /// <remarks/> 
    [System.Xml.Serialization.XmlAttributeAttribute()] 
    public ErrorCode error { 
     get { 
      return this.errorField; 
     } 
     set { 
      this.errorField = value; 
      this.RaisePropertyChanged("error"); 
     } 
    } 

    /// <remarks/> 
    [System.Xml.Serialization.XmlIgnoreAttribute()] 
    public bool errorSpecified { 
     get { 
      return this.errorFieldSpecified; 
     } 
     set { 
      this.errorFieldSpecified = value; 
      this.RaisePropertyChanged("errorSpecified"); 
     } 
    } 
} 

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")] 
[System.SerializableAttribute()] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:corp:iam:spml2:security")] 
public partial class SuggestUserIDResponseType : ResponseType { 

    private string[] uidField; 

    /// <remarks/> 
    [System.Xml.Serialization.XmlElementAttribute("uid", Order=0)] 
    public string[] uid { 
     get { 
      return this.uidField; 
     } 
     set { 
      this.uidField = value; 
      this.RaisePropertyChanged("uid"); 
     } 
    } 
} 

一つである

<?xml version="1.0" encoding="utf-8"?> 
<xsd:schema xmlns:spml="urn:oasis:names:tc:SPML:2:0" xmlns:sec="urn:corp:iam:spml2:security" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:corp:iam:spml2:security" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <xsd:import schemaLocation="../oasis-spml-xsds/pstc_spmlv2_core.xsd" namespace="urn:oasis:names:tc:SPML:2:0" /> 
    <xsd:complexType name="SuggestUserIDResponseType"> 
    <xsd:complexContent mixed="false"> 
     <xsd:extension base="spml:ResponseType"> 
     <xsd:sequence> 
      <xsd:element minOccurs="1" maxOccurs="5" name="uid" type="xsd:string" /> 
     </xsd:sequence> 
     </xsd:extension> 
    </xsd:complexContent> 
    </xsd:complexType> 
</xsd:schema> 

そして

<?xml version="1.0" encoding="utf-8"?> 
<xsd:schema xmlns:spml="urn:oasis:names:tc:SPML:2:0" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:oasis:names:tc:SPML:2:0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <xsd:complexType name="ExtensibleType"> 
    <xsd:sequence> 
     <xsd:any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax" /> 
    </xsd:sequence> 
    <xsd:anyAttribute namespace="##other" processContents="lax" /> 
    </xsd:complexType> 
    <xsd:complexType name="ResponseType"> 
    <xsd:complexContent mixed="false"> 
     <xsd:extension base="spml:ExtensibleType"> 
     <xsd:sequence> 
      <xsd:element minOccurs="0" maxOccurs="unbounded" name="errorMessage" type="xsd:string" /> 
     </xsd:sequence> 
     <xsd:attribute name="status" type="spml:StatusCodeType" use="required" /> 
     <xsd:attribute name="requestID" type="xsd:ID" use="optional" /> 
     <xsd:attribute name="error" type="spml:ErrorCode" use="optional" /> 
     </xsd:extension> 
    </xsd:complexContent> 
    </xsd:complexType> 
</xsd:schema> 

です返されたSOAPメッセージは

です
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <ns3:suggestUserIDResponse status="success" requestID="MyApp" xmlns="urn:oasis:names:tc:SPML:2:0" xmlns:ns2="urn:oasis:names:tc:SPML:2:0:password" xmlns:ns3="urn:corp:iam:spml2:security" xmlns:ns4="urn:oasis:names:tc:SPML:2:0:suspend" xmlns:ns5="urn:oasis:names:tc:SPML:2:0:search" xmlns:ns6="urn:oasis:names:tc:SPML:2:0:DSML" xmlns:ns7="urn:oasis:names:tc:DSML:2:0:core" xmlns:ns8="urn:oasis:names:tc:SPML:2:0:batch"> 
     <ns3:uid>text1</ns3:uid> 
     <ns3:uid>text2</ns3:uid> 
     <ns3:uid>text3</ns3:uid> 
     </ns3:suggestUserIDResponse> 
    </soap:Body> 
</soap:Envelope> 

SOAPが正しくSuggestUserIDResponseTypeクラスにdeserialzedていなかったその時点で、SuggestUserIDResponseType.uidは常にnullですが、繰り返しuidが唯一SuggestUserIDResponseType.AnyXmlElementなどのデータ型に表示されます。

何が間違っていますか?

+0

Web Referenceを使用するように変更されましたが、現在は正常に動作していますが、フードの違いは何ですか? – hardywang

+1

意図的な違いはなく、バグは違っています... –

答えて

0

私はちょうど同じ問題に出くわしました。問題はXmlAnyElementAttribute属性で修飾されたpublic System.Xml.XmlElement[] Anyプロパティの組み合わせとOrder修飾子が設定されているように見えます。 XmlElement[] Any配列を持つ基底クラスから継承する場合にのみ発生することもあります。

私の場合は解決

XmlElementAttribute attibutes、 XmlAnyElementAttribute属性と MessageBodyMemberAttribute属性継承されたすべてのクラス全体 で注文修飾子を削除することでした。

注:

型のメンバ「XYZ」「ABC_Type」で宣言された必要な不足している「注文」 プロパティ:太字、斜体でそのビットがそうでなければあなたのようなエラー何かを得るでしょうが重要です。クラス階層内の1つのクラスは、明示的な シーケンシング機能(注文)を使用している場合は、その基底クラスとすべてが のクラスは、私がしている可能性どのような副作用をチェックするための研究を行っていない同じ

を行う必要があり得これから重要なことの1つは、クラス内の正しい順序でプロパティを設定して、シリアル化が正しい順序で行われるようにすることです。

希望すると、誰かに役立ちます。