Java SOAP "wsimport" - force wrapped binding from document/literal wrapped WSDL?
Asked Answered
M

2

15

The Java 6 JAX-WS "wsimport" utility does a great job of generating a web service skeleton (interface) given a WSDL file but with one personally annoying exception.

When given a WSDL that uses the SOAP Document/literal wrapped style (also described here) it generates a service interface with a "bare" SOAP binding parameter style (with multiple arguments and return values expanded as "holder" objects in the method signatures) instead of the simple wrapped parameter and return value specified by the WSDL. Other tools, such as Axis2 wsdl2java simply use the wrapper elements as the input parameter and return value instead of automatically "unwrapping" them.

Is it possible to tell "wsimport" to keep the SOAP binding parameters as "wrapped" instead of "bare"?

Miscount answered 11/8, 2011 at 20:27 Comment(0)
E
39

AFAIK, you'd need to specify a custom binding file to disable the wrapper style:

<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>

and then invoke wsimport

$ wsimport -b binding.xml OperationService.wsdl
Earle answered 15/8, 2011 at 0:36 Comment(0)
M
15

The answer from @beny23 is on the right track; however, it turns out that you can embed the JAX-WS binding instructions into the WSDL file itself, which eliminates the need to add the "-b binding.xml" switches to the "wsimport" command:

<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>
Miscount answered 16/8, 2011 at 0:43 Comment(2)
But doesn't that then impact all users of the WSDL? So if you don't want wrappers on your side (either client or server), but your partner does on the other side, you've hindered them?Intussusception
@Intussusception yes, it would seem so, for JAX-WS users at least; I just wanted to point out another option in case it is more suitable for some users (such as myself =P)Miscount

© 2022 - 2024 — McMap. All rights reserved.