Java Reference
In-Depth Information
NOTE
Remember that you can see the outgoing SOAP message traffic by using the HttpTransportPipe
class that comes with the webservices-rt.jarin Glassfish. Even if you're developing on another plat-
form, this is very easy and helpful. Just add the following line to your command-line invocation:
-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
Of course, if you're running from within an IDE, you can include this VM argument in your run con-
figuration. In NetBeans 6, just right-click on the project name, click Run, and add it to the VM op-
tions field. In Eclipse, click Run→Open Run Dialog, then choose the Arguments tab. Enter the value
in the VM Arguments field and click Apply.
Making the client invocation sends the following SOAP message to the server:
---[HTTP request]---
SOAPAction: ""
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg,
*;
q=.2, */*; q=.2
Content-Type: text/xml;charset="utf-8"
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<ns2:username xmlns:ns2="http://soacookbook.com/">eben</ns2:username>
<ns2:password xmlns:ns2="http://soacookbook.com/">secret</ns2:password>
</S:Header>
<S:Body>
<ns2:verify xmlns:ns2="http://soacookbook.com/">
<email>me@example.com</email></ns2:verify>
</S:Body>
</S:Envelope>
So despite the Java client view, which has you send headers wrapped in a holder for the regular
method invocation, the username and password values do actually get sent to the service as
SOAP headers as expected.
Using Headers.create and JAXB
There is an option to use Headers.create as a convenience. However, this works only with
the reference implementation, although similar functionality may be available in other plat-
forms such as WebLogic (after all, WebLogic 10gR3 is a modified Glassfish under the hood).
Also, you cannot use this method with a WSDL such as the one in the previous example if you
create proxies for it. That is, the operations accept the headers as if they were regular method
parameters, so the proxy method will be expecting the holders.
Search WWH ::




Custom Search