Java Reference
In-Depth Information
location="http://localhost:8080/GatewayService/Gateway">
</soap:address>
</port>
</service>
</definitions>
For the sake of simplicity, this example puts the types directly into the schema itself. That's
acceptable for an example this straightforward, but is probably not something you'd want to
do in practice. You define one operation named authorize , which takes and returns a string.
Now you'll define your provider. Because you want to add headers, you'll use SOAPMessage
as the type parameter, which means you also have to specify @ServiceMode(Mode.MESSAGE) .
NOTE
There are certain combinations of service mode that don't make sense with your provider's type
parameter. For example, it is an error to attempt to parameterize your provider on
javax.xml.soap.SOAPMessage , and then specify Mode.PAYLOAD (which is also the default).
To rectify this, if you really only want the payload, use a Source type; if you really want access
to the whole SOAP message, including its headers and attachments, employ @Ser-
viceMode(Mode.MESSAGE) .
Example 7-11 shows a simple Provider implementation.
Example7-11.Provider<SOAPMessage> implementation
package com.soacookbook.ch04;
import java.io.IOException;
import java.util.UUID;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Provider;
import javax.xml.ws.Service.Mode;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
import org.apache.log4j.Logger;
Search WWH ::




Custom Search