在c#中使用Axis 1.4 Web服务始终为null

时间:2013-07-15 08:30:32

标签: c# web-services wsdl axis

我有一个在JBoss上运行的Axis 1.4 Web服务。请求没问题,但我无法使用c#在我的Windows 8商店应用程序中反序列化来自轴的响应。我得到一个对象myMethodRespone,它是null。我只是通过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>

有人能帮助我吗?

0 个答案:

没有答案