Archive

Posts Tagged ‘axis2’

Lotus/Domino 8.5 WebService Consumer manipulating SOAP Header

July 28, 2010 Leave a comment

There is pretty often a need to incorporate SOAP Header in the message sent by Web Service consumer. While Domino 8.5 is using Axis Java library under the hood of it’s generated Java Web Service Consumers,it blocks standard setHeader API in the client proxy. We had to look through all generated java files to find the solution. Below is example of sending SOAP Header from Lotus Web Consumer agent.

In the generated by Domino class for endpoint – XXXEndpointStub.java locate the code responsible for making the call, similar to the following:

lotus.domino.websvc.client.Call _call = createCall("submitRequest");
java.lang.Object _resp = _call.invoke(new java.lang.Object[] {parameters});

Modify it to create and addHeader before call invocation.For example to create following SoapHeader:

<soap:Envelope …>

<soap:Header>
<au:auth xmlns:au=”http://www.example.com“>
  <au:username>john</au:username>
</au.auth>
</soap:Header>

<soap:Body>
….
</soap:Body>
</soap:Envelope>

Code will be:

lotus.domino.websvc.client.Call _call = createCall("submitRequest");

try {
// Create soap header elements
SOAPHeaderElement header = new SOAPHeaderElement(“http://www.example.com&#8221;, “auth”);
SOAPElement elemSystem = header.addChildElement(“username”, “au”, “http://www.example.com&#8221;);
elemSystem.addTextNode(“john”);

// add header to payload
_call.addHeader(header);
} catch (Exception e) {
throw new ….
}

java.lang.Object _resp = _call.invoke(new java.lang.Object[] {parameters});