Skip Headers
Oracle® Fusion Middleware Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server
12c Release 1 (12.1.1)

Part Number E24965-02
Go to Documentation Home
Home
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

18 Sending and Receiving SOAP Headers

This chapter describes how use the methods available from com.sun.xml.ws.developer.WSBindingProvider to send outbound or receive inbound SOAP headers for WebLogic Web services using Java API for XML Web Services (JAX-WS).

This chapter includes the following sections:

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 javax.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 18-1 Sending SOAP Headers Using WSBindingProvider

import com.sun.xml.ws.developer.WSBindingProvider;
import com.sun.xml.ws.api.message.Headers;
import javax.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 18-2 Receiving SOAP Headers Using WSBindingProvider

import com.sun.xml.ws.developer.WSBindingProvider;
import com.sun.xml.ws.api.message.Headers;
import javax.xml.namespace.QName;
import java.util.List;
...
HelloService helloService = new HelloService();
HelloPort port = helloService.getHelloPort();
WSBindingProvider bp = (WSBindingProvider)port;
 
List inboundHeaders = bp.getInboundHeaders();
...