Java 6 JAX-WS "wsimport“实用程序在生成给定WSDL文件的web服务框架(接口)方面做得很好,但有一个令人讨厌的例外。
当给定一个使用SOAP Document/literal wrapped style (also described here)的WSDL时,它将生成一个带有“裸”SOAP binding parameter style (具有多个参数和返回值,在方法签名中展开为"holder" objects )的服务接口,而不是由WSDL指定的简单包装参数和返回值。其他工具,如Axis2 wsdl2java,只是使用包装器元素作为输入参数和返回值,而不是自动“解包”它们。
是否可以告诉"wsimport“将SOAP绑定参数保持为”封装“而不是”裸“?
发布于 2011-08-15 08:36:39
AFAIK,您需要指定一个自定义绑定文件来禁用包装器样式:
<bindings
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="OperationService.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws">
<!-- Disable default wrapper style -->
<enableWrapperStyle>false</enableWrapperStyle>
</bindings>然后调用wsimport
$ wsimport -b binding.xml OperationService.wsdl发布于 2011-08-16 08:43:39
来自@beny23的答案是正确的;然而,事实证明您可以使用embed the JAX-WS binding instructions into the WSDL file itself,这样就不需要在"wsimport“命令中添加"-b binding.xml”开关:
<wsdl:portType name="HelloPortType">
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>
<wsdl:operation name="sayHello">...</wsdl:operation>
</wsdl:portType>https://stackoverflow.com/questions/7032381
复制相似问题