25 Sending and Receiving SOAP Headers
com.sun.xml.ws.developer.WSBindingProvider
to send outbound or
receive inbound SOAP headers for WebLogic web services using Jakarta XML Web Services
(JAX-WS).Note:
The com.sun.xml.ws.developer.WSBindingProvider
and com.sun.xml.ws.api.message.Headers
APIs are supported as an extension to the JDK 6.0. Because the APIs are not provided as part of the JDK 6.0 kit, they are subject to change.
Overview of Sending and Receiving SOAP Headers
When you create a proxy or Dispatch client, the client implements the
jakarta.xml.ws.BindingProvider
interface. If you need to send or
receive a SOAP header, you can downcast the web service proxy or Dispatch client to
com.sun.xml.ws.developer.WSBindingProvider
and use the methods on
the interface to send outbound or receive inbound SOAP headers.
Sending SOAP Headers Using WSBindingProvider
Use the setOutboundHeaders
method to the com.sun.xml.ws.developer.WSBindingProvider
to send SOAP headers. You create SOAP headers using the com.sun.xml.ws.api.message.Headers
method.
For example, the following provides a code excerpt showing how to pass a simple string value as a header.
Example 25-1 Sending SOAP Headers Using WSBindingProvider
import com.sun.xml.ws.developer.WSBindingProvider; import com.sun.xml.ws.api.message.Headers; import jakarta.xml.namespace.QName; ... HelloService helloService = new HelloService(); HelloPort port = helloService.getHelloPort(); WSBindingProvider bp = (WSBindingProvider)port; bp.setOutboundHeaders( // Sets a simple string value as a header Headers.create(new QName("simpleHeader"),"stringValue") ); ...
Receiving SOAP Headers Using WSBindingProvider
Use the getInboundHeaders
method to the com.sun.xml.ws.developer.WSBindingProvider
to receive SOAP headers.
For example, the following provides a code excerpt showing how to get inbound headers.
Example 25-2 Receiving SOAP Headers Using WSBindingProvider
import com.sun.xml.ws.developer.WSBindingProvider; import com.sun.xml.ws.api.message.Headers; import jakarta.xml.namespace.QName; import java.util.List; ... HelloService helloService = new HelloService(); HelloPort port = helloService.getHelloPort(); WSBindingProvider bp = (WSBindingProvider)port; List inboundHeaders = bp.getInboundHeaders(); ...