【问题标题】:.NET client proxy consume AXIS web service.NET 客户端代理使用 AXIS Web 服务
【发布时间】:2014-03-12 14:33:25
【问题描述】:

我必须创建一个连接 Java AXIS Web 服务的 .NET Web 服务客户端。 我的问题与调用 WS 时返回一个包含 256 个元素的数组(这是正确的)有关,但每个元素的属性中都有空值。

wsdl如下:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://service.sms.mycompany.eu" 
                  xmlns:apachesoap="http://xml.apache.org/xml-soap" 
          xmlns:impl="http://service.sms.mycompany.eu" 
          xmlns:intf="http://service.sms.mycompany.eu" 
          **xmlns:tns1="http://model.sms.mycompany.eu"** 
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
          xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" 
          targetNamespace="http://service.sms.mycompany.eu" 
          xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://model.sms.mycompany.eu"/>
   <element name="getCountries">
    <complexType/>
   </element>
   <element name="getCountriesResponse">
    <complexType>
     <sequence>
      <element maxOccurs="unbounded" name="getCountriesReturn" type="**tns1:Country**"/>
     </sequence>
    </complexType>
   </element>
  </schema>
  <schema elementFormDefault="qualified" 
          targetNamespace="http://model.sms.mycompany.eu" 
          xmlns="http://www.w3.org/2001/XMLSchema">
   <complexType name="Country">
    <sequence>
     <element name="description" nillable="true" type="xsd:string"/>
     <element name="id" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>
   <wsdl:message name="getCountriesRequest">
      <wsdl:part element="impl:getCountries" name="parameters"></wsdl:part>
   </wsdl:message>
   <wsdl:message name="getCountriesResponse">
      <wsdl:part element="impl:getCountriesResponse" name="parameters"></wsdl:part>
   </wsdl:message>
   <wsdl:operation name="getCountries">
      <wsdl:input message="impl:getCountriesRequest" name="getCountriesRequest"></wsdl:input>
      <wsdl:output message="impl:getCountriesResponse" name="getCountriesResponse"></wsdl:output>
   </wsdl:operation>
   <wsdl:portType name="SapServiceOut">
      <wsdl:operation name="getCountries">
         <wsdl:input message="impl:getCountriesRequest" name="getCountriesRequest">
       </wsdl:input>
       <wsdl:output message="impl:getCountriesResponse" name="getCountriesResponse"></wsdl:output>
      </wsdl:operation>
   </wsdl:portType>

   <wsdl:binding name="SapServiceOutSoapBinding" type="impl:SapServiceOut">
      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="getCountries">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="getCountriesRequest">
            <wsdlsoap:body use="literal"/>
         </wsdl:input>
         <wsdl:output name="getCountriesResponse">
            <wsdlsoap:body use="literal"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="SapServiceOutService">
      <wsdl:port binding="impl:SapServiceOutSoapBinding" name="SapServiceOut">
         <wsdlsoap:address location="http://localhost:8080/XBP/services/SapServiceOut"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

我已经用 SoapUI 测试了服务,结果是这样的

<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>
      **<getCountriesResponse xmlns="http://service.sms.mycompany.eu">**
         <getCountriesReturn>
            <description>Afghanistan</description>
            <id>AF</id>
         </getCountriesReturn>
         <getCountriesReturn>
            <description>Antigua/Barbuda</description>
            <id>AG</id>
         </getCountriesReturn>
         ...
      </getCountriesResponse>
   </soapenv:Body>
</soapenv:Envelope>

我已经看到两个命名空间之间存在差异(在 ** 之间),但我仍然不明白如何更正 WSDL 以使其工作。

有人能以正确的方式称呼我吗? 非常感谢

【问题讨论】:

    标签: c# web-services asmx axis


    【解决方案1】:

    在响应中,所有对象都在同一个架构上,但在您的 wsdl 中,您使用另一个命名空间的类型定义 getCountriesReturn。您可以修复它,更改您的 wsdl 以在 http://service.sms.mycompany.eu 架构中包含 Country 类型:

    <wsdl:definitions targetNamespace="http://service.sms.mycompany.eu" 
                  xmlns:apachesoap="http://xml.apache.org/xml-soap" 
          xmlns:impl="http://service.sms.mycompany.eu" 
          xmlns:intf="http://service.sms.mycompany.eu" 
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
          xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)-->
    <wsdl:types>
        <schema elementFormDefault="qualified" 
          targetNamespace="http://service.sms.mycompany.eu" 
          xmlns="http://www.w3.org/2001/XMLSchema">
            <element name="getCountries">
                <complexType/>
            </element>
            <element name="getCountriesResponse">
                <complexType>
                    <sequence>
                        <element maxOccurs="unbounded" name="getCountriesReturn" type="Country"/>
                    </sequence>
                </complexType>
            </element>
            <complexType name="Country">
                <sequence>
                    <element name="description" nillable="true" type="xsd:string"/>
                    <element name="id" nillable="true" type="xsd:string"/>
                </sequence>
            </complexType>
        </schema>
    </wsdl:types>
    <wsdl:message name="getCountriesRequest">
        <wsdl:part element="impl:getCountries" name="parameters"/>
    </wsdl:message>
    <wsdl:message name="getCountriesResponse">
        <wsdl:part element="impl:getCountriesResponse" name="parameters"/>
    </wsdl:message>
    <wsdl:operation name="getCountries">
        <wsdl:input message="impl:getCountriesRequest" name="getCountriesRequest"/>
        <wsdl:output message="impl:getCountriesResponse" name="getCountriesResponse"/>
    </wsdl:operation>
    <wsdl:portType name="SapServiceOut">
        <wsdl:operation name="getCountries">
            <wsdl:input message="impl:getCountriesRequest" name="getCountriesRequest">
            </wsdl:input>
            <wsdl:output message="impl:getCountriesResponse" name="getCountriesResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    
    <wsdl:binding name="SapServiceOutSoapBinding" type="impl:SapServiceOut">
        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="getCountries">
            <wsdlsoap:operation soapAction=""/>
            <wsdl:input name="getCountriesRequest">
                <wsdlsoap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="getCountriesResponse">
                <wsdlsoap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SapServiceOutService">
        <wsdl:port binding="impl:SapServiceOutSoapBinding" name="SapServiceOut">
            <wsdlsoap:address location="http://localhost:8080/XBP/services/SapServiceOut"/>
        </wsdl:port>
    </wsdl:service>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      • 1970-01-01
      相关资源
      最近更新 更多