Java Reference
In-Depth Information
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<creditCard xmlns="http://ns.soacookbook.com/credit">
<cardNumber>4011111111111111</cardNumber>
<name>
<firstName>Phineas</firstName>
<middleInitial>J</middleInitial>
<lastName>Fogg</lastName>
</name>
<expirationDate>2015-04-27-07:00</expirationDate>
</creditCard></S:Body></S:Envelope>
If you were going to construct a credit card SOAP message by hand on the client to invoke
this service, this is what you would need to build using SAAJ. If you used
wsimport
and let
JAX-WS generate a
CreditCard
Java type for you on the client, you could just populate the
object as you would any other and pass it to the proxy to let it do the marshaling into this same
XML.
the wire.
Example7-5.SOAP message XML for authorization return
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<authorization xmlns="http://ns.soacookbook.com/credit">
<amount>2500.0</amount>
</authorization>
</S:Body>
</S:Envelope>
These XML documents are what's actually exchanged during service invocation, and in each
case the only child element of the SOAP body is a type that matches the corresponding schema
element exactly.
JAXB generated types
As mentioned, your parameter and return type are based on schema elements that XJC gen-
compile and use on the client side if you import the WSDL.
Example7-6.CreditCard.java
package com.soacookbook.ns.credit;