我正在尝试wsimport
或Apache CXF wsdl2java
为W3C WSDL 1.1 spec的“示例1”生成存根。 (也在帖子末尾逐字复制)。
该示例似乎有一个小错字,但即使更换后:
binding="tns:StockQuoteBinding
与
binding="tns:StockQuoteSoapBinding
wsimport 和 wsdl2java 仍然失败。
我试过wsimport
的命令行版本(JAX-WS RI 2.2.4)和Ant任务版本(JAX-WS RI 2.2.8)以及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 CXF wsdl2java
在一个稍微不同的消息中抱怨同一类型)
关于这个WSDL文件有什么问题的任何想法?
NB:您需要将binding="tns:StockQuoteBinding
更改为binding="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>