我尝试连接到 Amazon AWSECommerceService。我使用 CXF 生成客户端类并提供 WSDL,但我收到错误消息“操作 itemLookup 对此端点无效”。
一些调查让我想到了这一点:生成的 SOAP 消息就像:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:itemLookup
xmlns:ns1="http://_2011_08_01.awsecommerceservice.webservices.amazon.com/">
<ItemLookup
xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<AssociateTag>pkd</AssociateTag>
<Request>
<IdType>ISBN</IdType>
<ItemId>0321534468</ItemId>
<SearchIndex>Books</SearchIndex>
</Request>
</ItemLookup>
</ns1:itemLookup>
</soap:Body>
</soap:Envelope>
但它应该是:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ItemLookup
xmlns="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<AssociateTag>pkd</AssociateTag>
<Request>
<IdType>ISBN</IdType>
<ItemId>0321534468</ItemId>
<SearchIndex>Books</SearchIndex>
</Request>
</ItemLookup>
</soap:Body>
</soap:Envelope>
看起来有一个意想不到的标签
<ns1:itemLookup
xmlns:ns1="http://_2011_08_01.awsecommerceservice.webservices.amazon.com/">
第二个示例在使用 SoapUI 时效果很好。出了什么问题?我在运行 wsdl2java maven 插件时缺少什么?
如果问题很愚蠢,请原谅我。我对 web 服务和 SOAP 真的很陌生。
当我添加注释时:
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
我收到消息:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:itemLookup
xmlns:ns1="http://_2011_08_01.awsecommerceservice.webservices.amazon.com/">
<ns2:ItemLookup
xmlns:ns2="http://_2011_08_01.awsecommerceservice.webservices.amazon.com/"
xmlns:ns3="http://webservices.amazon.com/AWSECommerceService/2011-08-01">
<AssociateTag>pkd</AssociateTag>
<Shared>
<IdType>ISBN</IdType>
<ItemId>0321534468</ItemId>
<SearchIndex>Books</SearchIndex>
</Shared>
</ns2:ItemLookup>
</ns1:itemLookup>
</soap:Body>
</soap:Envelope>
这些命名空间对我来说很奇怪。