Posted By

lspellman on 12/16/12


header java soap webservice consumer

Versions (?)

Java method to add SOAP header

 / Published in: Java

Some webservices require a SOAP header to be added to requests (typically with authentication information). For Domino webservice consumer code, this can be handled by extending the generated stub class and rewriting the service calls that are being used. Those methods all execute a 'createCall'. After you have a handle to the call, you can call this custom method to add headers to it.

NOTE: The oli log methods are to a custom logger (OpenLog) which is setup elsewhere in the class. Delete if not using OpenLog.

  1. private lotus.domino.websvc.client.Call createSessionHeader(lotus.domino.websvc.client.Call _call) {
  2. try {
  3. // Create soap header elements
  4. String namespace = "urn.QueryService";
  5. lotus.domino.axis.message.SOAPHeaderElement header = new lotus.domino.axis.message.SOAPHeaderElement(namespace, "SessionHeaderValue");
  6. header.setMustUnderstand(false);
  7. SOAPElement elemSystem = header.addChildElement("sessionID","","");
  9. // check to see that we actually have the session id
  10. logMsg = "checking sessionID: " + this.sessionID;
  11. System.out.println(logMsg);
  12. oli.logEvent(logMsg, OpenLogItem.SEVERITY_LOW, null);
  14. elemSystem.addTextNode(this.sessionID);
  15. _call.addHeader(header);
  16. return _call;
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. oli.logError(e);
  20. return null;
  21. }
  22. }

Report this snippet  

You need to login to post a comment.