3

我有一个在 JBoss 上运行的 Axis 1.4 Web 服务。请求没问题,但我无法使用 c# 在我的 Windows 8 商店应用程序中反序列化来自轴的响应。我得到一个为空的对象 myMethodRespone。我只是通过 VS 中的 addServiceReference 添加服务。这是我的 WSDL(只有重要的代码片段):

<xsd:complexType name="ArrayOf_xsd_string">
    <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="unbounded" name="item" type="xsd:string" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="ArrayOf_tns1_AlternativeTransferable">
    <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="unbounded" name="item" type="tns1:MyTransferable" />
    </xsd:sequence>
  </xsd:complexType>
<xsd:complexType name="AlternativeTransferable">
    <xsd:sequence>
      <xsd:element name="alternativeList" nillable="true" type="impl:ArrayOf_xsd_string" />
    </xsd:sequence>
  </xsd:complexType>
<xsd:complexType name="MyTransferable">
    <xsd:sequence>
      <xsd:element name="alternatives" nillable="true"type="impl:ArrayOf_tns1_AlternativeTransferable" />
      <xsd:element name="mod" nillable="true" type="impl:ArrayOf_xsd_string" />
      <xsd:element name="msnList" nillable="true" type="impl:ArrayOf_xsd_string" />
    </xsd:sequence>
  </xsd:complexType>
  <wsdl:operation name="myMethod" parameterOrder="msnList epacCodes">
  <wsdl:input name="myMethodRequest" message="impl:myMethodRequest" />
  <wsdl:output name="myMethodResponse" message="impl:myMethodResponse" />
  <wsdl:fault name="WebServiceRequestException" message="impl:WebServiceRequestException" />
</wsdl:operation>
  <wsdl:message name="myMethodResultResponse">
<wsdl:part name="myMethodReturn" type="tns1:MyTransferable" />
</wsdl:message>

从 Visual Studio 生成的代理如下所示:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="myMethodResponse", WrapperNamespace="http://localhost:8080/H970live/services/Configuration", IsWrapped=true)]
public partial class myMethodResponse {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
    public MyProject.Model.MyTransferable myMethodReturn;

    public myMethodResponse() {
    }

    public myMethodResponse(MyProject.Model.MyTransferable myMethodReturn) {
        this.myMethodReturn = myMethodReturn;
    }
}
  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18213")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://entity.webservice.server.de")]
public partial class MyTransferable : object, System.ComponentModel.INotifyPropertyChanged {

    private AlternativeTransferable[] alternativesField;

    private string[] modField;

    private string[] msnListField;

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=0)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public AlternativeTransferable[] alternatives {
        get {
            return this.alternativesField;
        }
        set {
            this.alternativesField = value;
            this.RaisePropertyChanged("alternatives");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=1)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public string[] mod {
        get {
            return this.modField;
        }
        set {
            this.modField = value;
            this.RaisePropertyChanged("mod");
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=2)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public string[] msnList {
        get {
            return this.msnListField;
        }
        set {
            this.msnListField = value;
            this.RaisePropertyChanged("msnList");
        }
    }

    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.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18213")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://entity.webservice.server.de")]
public partial class AlternativeTransferable : object, System.ComponentModel.INotifyPropertyChanged {

    private string[] alternativeList;

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true, Order=0)]
    [System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public string[] epacTdus {
        get {
            return this.alternativeList;
        }
        set {
            this.alternativeList = value;
            this.RaisePropertyChanged("epacTdus");
        }
    }

    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));
        }
    }
}
}

这是我在 svcmap 文件中的客户端选项:

<ClientOptions>
<GenerateAsynchronousMethods>false</GenerateAsynchronousMethods>
<GenerateTaskBasedAsynchronousMethod>true</GenerateTaskBasedAsynchronousMethod>
<EnableDataBinding>true</EnableDataBinding>
<ExcludedTypes />
<ImportXmlTypes>false</ImportXmlTypes>
<GenerateInternalTypes>false</GenerateInternalTypes>
<GenerateMessageContracts>false</GenerateMessageContracts>
<NamespaceMappings />
<CollectionMappings>
  <CollectionMapping TypeName="System.Collections.ObjectModel.ObservableCollection`1" Category="List" />
</CollectionMappings>
<GenerateSerializableTypes>false</GenerateSerializableTypes>
<Serializer>Auto</Serializer>
<UseSerializerForFaults>false</UseSerializerForFaults>
<ReferenceAllAssemblies>true</ReferenceAllAssemblies>
<ReferencedAssemblies />
<ReferencedDataContractTypes />
<ServiceContractMappings />

响应如下所示:

     <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<myMethodResponse xmlns="http://webservice.server.de">
<myMethodReturn>
<alternatives>
    <alternatives>
        <alternativeList/>
    </alternatives>
</alternatives>
<mod>
    <mod>CN22.00.998-01</mod>
</mod>
<msnList>
<msnList>N-2228</msnList>
<msnList>N-2456</msnList>
<msnList>N-2213</msnList>
<msnList>N-2716</msnList>
<msnList>N-3065</msnList>
</msnList>
</myMethodReturn>
</myMethodResponse>
</soapenv:Body></soapenv:Envelope>

有谁能够帮我?

4

0 回答 0