9

当我使用 wsimport 为某些服务生成代理时,生成的每个端口的方法签名似乎没有使用 WSDL 中指定的复杂类型;但我注意到它与其他一些服务一样。

这发生在多项服务上,但最近的例子是亚马逊的 AWSEConsumerService(链接到 WSDL)。当我使用 wsimport 生成服务代理代码时,我会为每个端口获得如下方法签名。

@WebMethod(operationName = "ItemLookup", action = "http://soap.amazon.com/ItemLookup")
@RequestWrapper(localName = "ItemLookup", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01", className = "com.aws.CommerceService.ItemLookup")
@ResponseWrapper(localName = "ItemLookupResponse", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01", className = "com.aws.CommerceService.ItemLookupResponse")
public void itemLookup(
    @WebParam(name = "MarketplaceDomain", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01")
    String marketplaceDomain,
    @WebParam(name = "AWSAccessKeyId", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01")
    String awsAccessKeyId,
    @WebParam(name = "AssociateTag", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01")
    String associateTag,
    @WebParam(name = "Validate", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01")
    String validate,
    @WebParam(name = "XMLEscaping", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01")
    String xmlEscaping,
    @WebParam(name = "Shared", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01")
    ItemLookupRequest shared,
    @WebParam(name = "Request", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01")
    List<ItemLookupRequest> request,
    @WebParam(name = "OperationRequest", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01", mode = WebParam.Mode.OUT)
    Holder<OperationRequest> operationRequest,
    @WebParam(name = "Items", targetNamespace = "http://webservices.amazon.com/AWSECommerceService/2011-08-01", mode = WebParam.Mode.OUT)
    Holder<List<Items>> items);

我希望此方法采用 WSDL 指定的单个复杂参数(在本例中为 ItemLookup 对象)。我是从根本上误解了什么还是代码生成发生了异常?

4

1 回答 1

8

我在 AWS 上遇到了类似的问题。我遵循了 Java 的 API 设置描述(本pdf的第 10 页

在第 2 步(它表示 Eclipse 3.2)中,您应该创建一个包含以下内容的文件(建议名称为 jaxws-custom.xml):

<jaxws:bindings wsdlLocation="http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
 <jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>

然后使用选项 -b jaxws-custom.xml 运行 wsimport 命令

我还没有弄清楚到底是什么问题,但这对我有用。

于 2011-11-09T18:44:51.427 回答