当我使用wsimport为某些服务生成代理时,每个端口的结果方法签名似乎不使用WSDL中指定的复杂类型;但是我注意到它有一些其他服务。
这发生在多个服务上,但最近的例子是亚马逊的AWSEConsumerService(link to 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对象)。我是否从根本上误解了某些东西,或者代码生成是否发生了异常?
答案 0 :(得分:7)
我遇到了与AWS类似的问题。我遵循了Java的API设置描述(本pdf
的第10页)在第2步(对于Eclipse 3.2说)中,您应该创建一个文件(sugessted name是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命令我还没弄清楚究竟是什么问题,但这对我有用。