0

我正在开始使用 Spring Web 服务,但我已经从 w3school 网站下载了 WSDL,但是当我尝试为此 WSDL 创建客户端时,我没有在 SpringSource 中获得 JAXB 选项,它只显示 apache 轴和 apache 轴 2。请告诉我如何使用 springSource 从 WSDL 生成 Web 服务客户端。虽然我已经添加了 JAXB 插件是 spring 源另一件事是如果我使用 apache axis2 ii 无法找到服务请帮助我理解。

wsdl 是

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <s:element name="FahrenheitToCelsius">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="Fahrenheit" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="FahrenheitToCelsiusResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="FahrenheitToCelsiusResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="CelsiusToFahrenheit">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="Celsius" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="CelsiusToFahrenheitResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="CelsiusToFahrenheitResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="string" nillable="true" type="s:string" />
    </s:schema>
  </wsdl:types>
  <wsdl:message name="FahrenheitToCelsiusSoapIn">
    <wsdl:part name="parameters" element="tns:FahrenheitToCelsius" />
  </wsdl:message>
  <wsdl:message name="FahrenheitToCelsiusSoapOut">
    <wsdl:part name="parameters" element="tns:FahrenheitToCelsiusResponse" />
  </wsdl:message>
  <wsdl:message name="CelsiusToFahrenheitSoapIn">
    <wsdl:part name="parameters" element="tns:CelsiusToFahrenheit" />
  </wsdl:message>
  <wsdl:message name="CelsiusToFahrenheitSoapOut">
    <wsdl:part name="parameters" element="tns:CelsiusToFahrenheitResponse" />
  </wsdl:message>
  <wsdl:message name="FahrenheitToCelsiusHttpPostIn">
    <wsdl:part name="Fahrenheit" type="s:string" />
  </wsdl:message>
  <wsdl:message name="FahrenheitToCelsiusHttpPostOut">
    <wsdl:part name="Body" element="tns:string" />
  </wsdl:message>
  <wsdl:message name="CelsiusToFahrenheitHttpPostIn">
    <wsdl:part name="Celsius" type="s:string" />
  </wsdl:message>
  <wsdl:message name="CelsiusToFahrenheitHttpPostOut">
    <wsdl:part name="Body" element="tns:string" />
  </wsdl:message>
  <wsdl:portType name="TempConvertSoap">
    <wsdl:operation name="FahrenheitToCelsius">
      <wsdl:input message="tns:FahrenheitToCelsiusSoapIn" />
      <wsdl:output message="tns:FahrenheitToCelsiusSoapOut" />
    </wsdl:operation>
    <wsdl:operation name="CelsiusToFahrenheit">
      <wsdl:input message="tns:CelsiusToFahrenheitSoapIn" />
      <wsdl:output message="tns:CelsiusToFahrenheitSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="TempConvertHttpPost">
    <wsdl:operation name="FahrenheitToCelsius">
      <wsdl:input message="tns:FahrenheitToCelsiusHttpPostIn" />
      <wsdl:output message="tns:FahrenheitToCelsiusHttpPostOut" />
    </wsdl:operation>
    <wsdl:operation name="CelsiusToFahrenheit">
      <wsdl:input message="tns:CelsiusToFahrenheitHttpPostIn" />
      <wsdl:output message="tns:CelsiusToFahrenheitHttpPostOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="TempConvertSoap" type="tns:TempConvertSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="FahrenheitToCelsius">
      <soap:operation soapAction="http://tempuri.org/FahrenheitToCelsius" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="CelsiusToFahrenheit">
      <soap:operation soapAction="http://tempuri.org/CelsiusToFahrenheit" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="TempConvertSoap12" type="tns:TempConvertSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="FahrenheitToCelsius">
      <soap12:operation soapAction="http://tempuri.org/FahrenheitToCelsius" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="CelsiusToFahrenheit">
      <soap12:operation soapAction="http://tempuri.org/CelsiusToFahrenheit" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="TempConvertHttpPost" type="tns:TempConvertHttpPost">
    <http:binding verb="POST" />
    <wsdl:operation name="FahrenheitToCelsius">
      <http:operation location="/FahrenheitToCelsius" />
      <wsdl:input>
        <mime:content type="application/x-www-form-urlencoded" />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="CelsiusToFahrenheit">
      <http:operation location="/CelsiusToFahrenheit" />
      <wsdl:input>
        <mime:content type="application/x-www-form-urlencoded" />
      </wsdl:input>
      <wsdl:output>
        <mime:mimeXml part="Body" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="TempConvert">
    <wsdl:port name="TempConvertSoap" binding="tns:TempConvertSoap">
      <soap:address location="http://www.w3schools.com/webservices/tempconvert.asmx" />
    </wsdl:port>
    <wsdl:port name="TempConvertSoap12" binding="tns:TempConvertSoap12">
      <soap12:address location="http://www.w3schools.com/webservices/tempconvert.asmx" />
    </wsdl:port>
    <wsdl:port name="TempConvertHttpPost" binding="tns:TempConvertHttpPost">
      <http:address location="http://www.w3schools.com/webservices/tempconvert.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
4

1 回答 1

1

JAXB 是一种从 XML 创建 Java 对象的 API,反之亦然。大多数 Web 服务工具在内部使用 JAXB 来解析您的 wsdl。当您使用 eclipse 服务客户端创建时,您应该会看到许多生成的源文件,其中一个是代理类,另一个代表端口类型。Jdk 提供了名为 Service 的 API,您可以使用它来创建实例,然后调用服务实现方法。

Web 服务客户端创建在任何 Eclipse IDE 中都很常见,这里有一些有用的链接

http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/bu_tutorial.html

http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jst.ws.cxf.doc.user%2Ftasks%2Fcreate_client.html 1

如何在 Eclipse 中创建 Axis2 Web 服务客户端?

于 2012-10-16T19:50:43.333 回答