uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

36.7.3 Setting the SOAP Header that can be processed

In this subsection, the method of setting up a SOAP Header that can be processed will be described with respect to the handler, the Web Service Implementation Class, and the Web Service client.

Organization of this subsection
(1) To set the SOAP Header using the handler
(2) To set the SOAP Header using the Web Service Implementation Class
(3) To set the SOAP Header using the Web Service client

(1) To set the SOAP Header using the handler

Create the handler class implementing the javax.xml.ws.handler.soap.SOAPHandler interface and use the getHeaders() method to return java.util.Set containing QName of the SOAP Header that can be processed. The following is an example of settings in the handler:

public class MySOAPHandler implements SOAPHandler<SOAPMessageContext> {
 private final static Set<QName> headers;
 
 static {
 headers = new HashSet<QName>();
 headers.add(new QName("http://test.org/handler/", "headerA"));
 }
 
 public Set<QName> getHeaders(){
 return headers;
 }
 (The-rest-of-the-implementation-is-omitted)
}

(2) To set the SOAP Header using the Web Service Implementation Class

For the development of Web Services starting from SEI, define a method with an argument annotated using the javax.jws.WebParam annotation in the Web Service Implementation Class. Define the following settings in the javax.jws.WebParam annotation:

The following is an example of settings in the Web Service Implementation Class:

@WebService
@SOAPBinding (parameterStyle= javax.jws.soap.SOAPBinding.ParameterStyle.BARE)
@HandlerChain (file="handlerchainfile.xml")
public class MyWebService{
 @WebMethod(operationName = "webMethod")
 public String webMethod(
 @WebParam(targetNamespace="http://test.org/handler/", name="message")
 String message, 
 @WebParam(targetNamespace="http://test.org/handler/", name="headerS", header = true, WebParam.Mode.IN)
 String headerS
 ){
 (The-rest-of-the-implementation-is-omitted)
}
}

For the development of Web Services starting from WSDL, code the soap:header element in WSDL within the range supported in WSDL 1.1 specifications and Cosminexus JAX-WS functionality. For details about the coding of the soap:header element in the Cosminexus JAX-WS functionality, see 20.1.22 soap:header element.

(3) To set the SOAP Header using the Web Service client

If WSDL that is the Metadata of the connected Web Service, contains the soap:header element, that soap:header element can be processed. The following is an example of WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:tns="http://test.org/handler/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://schemas.xmlsoap.org/wsdl/"
  targetNamespace="http://test.org/handler/"
  name="HandlerTest01Service">
 
 <types>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  version="1.0"
  targetNamespace="http://test.org/handler/">
 <xs:element name="headerCL" nillable="true" type="xs:string"></xs:element>
 <xs:element name="message" nillable="true" type="xs:string"></xs:element>
 <xs:element name="testResponse" nillable="true" type="xs:string"></xs:element>
 </xs:schema>
 </types>
 
<message name="test">
 <part name="message" element="tns:message"></part>
 <part name="headerCL" element="tns:headerCL"></part>
 </message>
 <message name="testResponse">
 <part name="testResponse" element="tns:testResponse"></part>
 <part name="headerCL" element="tns:headerCL"></part>
 </message>
 
 <portType name="HandlerTest01">
 <operation name="test" parameterOrder="message headerCL">
 <input message="tns:test"></input>
 <output message="tns:testResponse"></output>
 </operation>
 </portType>
 
<binding name="HandlerTest01Binding" type="tns:HandlerTest01">
 <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
 <operation name="test">
 <soap:operation soapAction=""></soap:operation>
 <input>
 
<soap:body use="literal" parts="message"></soap:body>
 <soap:header message="tns:test" part="headerCL" use="literal"></soap:header>
 </input>
 <output>
 
<soap:body use="literal" parts="testResponse"></soap:body>
 <soap:header message="tns:testResponse" part="headerCL" use="literal"></soap:header>
 </output>
 </operation>
 </binding>
 
<service name="HandlerTest01Service">
 <port name="HandlerTest01Port" binding="tns:HandlerTest01Binding">
 <soap:address location="http://localhost:80/SOAPHeaderTest/HandlerTestService431"></soap:address>
 </port>
 </service>
</definitions>

In this case, the SOAP Header with element name {http://test.org/handler/}headerCL can be processed. For details about the soap:header element of a WSDL, see 20.1.22 soap:header element.