To Whom It May Concern:

I am using Rad7, Ibm Websphere 6.1, on Windows XP.
I created an SoapHeader first using a string and bind it using jax-ws.
It works for jax-ws but unfortunately, my work services uses jax-rpc.
Does anybody know how to bind the soap header using jax-rpc.

Any help or hint would be greatly appreciated it.

Here is my code:


import org.apache.cxf.headers.Header;
import org.apache.cxf.headers.Header.Direction;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.binding.soap.SoapHeader;

import javax.xml.namespace.QName;
import java.io.StringReader;
import java.util.List;
import java.util.ArrayList;
import javax.xml.ws.BindingProvider;


@Test
public void testService() throws Exception {
try
{

URL wsdlURL = new URL("http://localhost:9087/abc/services/ServiceABCService");
ServiceRequestServiceService service = new ServiceRequestServiceServiceLocator();
ServiceRequestService port = service.getServiceRequestService(wsdlURL);

//How to Add Soap Header using jax-ws


String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ABCHdrRq "
+ "xmlns=\"http://xmlns.ABCgc.net/ABC/2002/header/\" "
+ ">"
+ "<version>1.0</version><srcInfo><chType>abc</chType><chInst>0124</chInst>" +
"<appName>sSAR</appName><hostName>ABC70210521</hostName><userId>fxue</userId>" +
"</srcInfo><startTimeStamp>2010-06-04T13:44:45.132</startTimeStamp><clientDt>2010-06-04T13:44:53.242</clientDt><serviceInfo><serviceName>ServiceRequestS ervice</serviceName>" +
"<serviceFunc>addServiceTimeRequest</serviceFunc></serviceInfo>" +
"<prevTransInfo><prevRqUID>BORS2010-06-04T13:41:10.2067f9368d1-8c5c</prevRqUID>" +
"<prevRespTimestamp>2010-06-04T13:41:10.871</prevRespTimestamp>"+
"<prevRespEndTimestamp>2010-06-04T13:41:10.902</prevRespEndTimestamp>+</prevTransInfo>"+
"</ABCHdrRq>";
SoapHeader dummyHeader1 = new SoapHeader(new QName("uri:http://xmlns.ABCgc.net/ABC/2002/header/", "ABCHdrRq"),
DOMUtils.readXml(new StringReader(xml)).getDocumentElement());
dummyHeader1.setDirection(Direction.DIRECTION_OUT) ;
List<Header> headers = new ArrayList<Header>();
headers.add(dummyHeader1);

((BindingProvider)port).getRequestContext().put(He ader.HEADER_LIST, headers);

//How to Add Soap Header to the request using jax-ws

}
catch(Exception e)
{
System.out.println("Exception message:"+e.getMessage());
}
}

Yours,

Frustrated