There are many WSDLs out there that define SOAP headers in binding section, but not in portType section. More often than not this is not intentional (mostly found in .NET generated WSDLs) and can cause unwanted side effects. One of these effects is that JAX-WS RI wsimport tool won't generate header parameters for operations.
As a solution you can always cast your port object to WSBindingProvider and use setOutboundHeader function, but that's a bit messy. JAX-WS documentation goes even further saying that "The portable way of doing this is that you create a SOAPHandler and mess with SAAJ". Ugh, not good.
But there is one simple, clean and easy solution. If you are using JAX-WS RI 2.1.3 (released December 18, 2007, Metro 1.1 includes it) or newer then wsimport has a new option: -XadditionalHeaders. Use this option when you have a WSDL with additional headers that are not part of portType contract.
10 years ago
No comments:
Post a Comment