1

我正在尝试获取wsimport或 Apache CXF为W3C WSDL 1.1 规范wsdl2java的“示例 1”生成存根。(也在帖子末尾逐字复制)。

该示例似乎有一个小错字,但即使在替换后:

binding="tns:StockQuoteBinding

binding="tns:StockQuoteSoapBinding

wsimportwsdl2java仍然失败。

我试过了,命令行版本(JAX-WS RI 2.2.4)和Ant Task 版本(JAX-WS RI 2.2.8)wsimport以及Apache CXF wsdl2java(2.7.6)的命令行版本。他们似乎都或多或少地出于相同的原因而失败:

$ wsimport -version
JAX-WS RI 2.2.4-b01
$ wsimport -d src-auto-wsimport/ -p foo.client  -Xnocompile specs/example1.wsdl 
parsing WSDL...


[ERROR] Schema descriptor {http://example.com/stockquote.xsd}TradePriceRequest in message part "body" is not defined and could not be bound to Java. Perhaps the schema descriptor {http://example.com/stockquote.xsd}TradePriceRequest is not defined in the schema imported/included in the WSDL. You can either add such imports/includes or run wsimport and provide the schema location using -b switch.
 line 31 of file:/home/brutus/jax-ws/wsdl/specs/example1.wsdl

据我所知,它所抱怨的类型 ( TradePriceRequest) 在 WSDL 文件中提供的模式中得到了正确定义,所以我看不出它为什么找不到它。(Apache CXFwsdl2java在稍有不同的消息中也抱怨相同的类型)

关于这个 WSDL 文件有什么问题的任何想法?

示例 1 WSDL(来自上面链接的 W3C WSDL 1.1 规范的逐字记录)

注意:您需要更改binding="tns:StockQuoteBindingbinding="tns:StockQuoteSoapBinding

<?xml version="1.0"?>
<definitions name="StockQuote"

targetNamespace="http://example.com/stockquote.wsdl"
      xmlns:tns="http://example.com/stockquote.wsdl"
      xmlns:xsd1="http://example.com/stockquote.xsd"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>
   <schema targetNamespace="http://example.com/stockquote.xsd"
          xmlns="http://www.w3.org/2000/10/XMLSchema">
       <element name="TradePriceRequest">
          <complexType>
              <all>
                  <element name="tickerSymbol" type="string"/>
              </all>
          </complexType>
       </element>
       <element name="TradePrice">
          <complexType>
              <all>
                  <element name="price" type="float"/>
              </all>
          </complexType>
       </element>
   </schema>
</types>

<message name="GetLastTradePriceInput">
    <part name="body" element="xsd1:TradePriceRequest"/>
</message>

<message name="GetLastTradePriceOutput">
    <part name="body" element="xsd1:TradePrice"/>
</message>

<portType name="StockQuotePortType">
    <operation name="GetLastTradePrice">
       <input message="tns:GetLastTradePriceInput"/>
       <output message="tns:GetLastTradePriceOutput"/>
    </operation>
</portType>

<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="GetLastTradePrice">
       <soap:operation soapAction="http://example.com/GetLastTradePrice"/>
       <input>
           <soap:body use="literal"/>
       </input>
       <output>
           <soap:body use="literal"/>
       </output>
    </operation>
</binding>

<service name="StockQuoteService">
    <documentation>My first service</documentation>
    <port name="StockQuotePort" binding="tns:StockQuoteBinding">
       <soap:address location="http://example.com/stockquote"/>
    </port>
</service>

</definitions>
4

0 回答 0