In a current project we’re using the web service consumer and web server provider capability of Lotus Domino quite heavily. During the development the need to process the SOAP request headers which are provided in a section above the SOAP body. Problem is that these are not exposed through the proxy classes generated for you when you import the WSDL. Searching Google I came across the blog of Elena Neroslavskaya and more importantly the post that helped me out. Using the MessageContext class described in that blog post helped me crack the nut and now I can both iterate through the SOAP headers sent to me in the request and send SOAP headers back in the response. Sweet!
Below are two code snippets – one for iterating through request headers and one for sending headers back. Home it may help someone out there.
Iterate received headers
private void recurseHeaders(Iterator ite) { while (ite.hasNext()) { MessageElement elem = (MessageElement)ite.next(); String nsUri = elem.getNamespaceURI(); String name = elem.getName(); String value = elem.getValue(); System.out.println("SOAP Header - ns , name , value "); this.recurseHeaders(elem.getChildElements()); } } public com.example.FooResponseType foo( com.example.FooRequestType req) throws Exception { MessageContext mc = MessageContext.getCurrentContext(); SOAPEnvelope envelope = mc.getRequestMessage() .getSOAPEnvelope(); this.recurseHeaders( envelope.getHeader().getChildElements()); }
Send back headers
import lotus.domino.axis.message.SOAPHeaderElement; import lotus.domino.axis.message.MessageElement; MessageElement elemGuid = new MessageElement("http://lekkimworld.com", "Guid"); elemGuid.addTextNode("GuidXYZ"); MessageElement elemUser = new MessageElement("http://lekkimworld.com", "User"); elemUser.addTextNode("UserXYZ"); SOAPHeaderElement elemHeader = new SOAPHeaderElement("http://lekkimworld.com", "TopElem"); elemHeader.addChild(elemGuid); elemHeader.addChild(elemUser); mc.getResponseMessage() .getSOAPEnvelope().addHeader(elemHeader);
http://./files/prettyprint/prettify.js
prettyPrint();
Hi,
i’m sorry for my english. Is possible to do the same thing with lotusscript?
I have the necessity to add a header for user authentication.
Can you post me a sample if possible? My email is m_campisi@oasi-net.it
LikeLike
I haven’t tried in LotusScript I’m affraid so I do not know.
LikeLike
Hi;
I cannot call this web service Even SOAP. How to call could you please help me
http://www.mobilefish.com/services/web_service/countries.php?wsdl
LikeLike
Looks pretty straight forward. Are you using Domino?
LikeLike
are we able to get the SOAP header information through LotusScript?
LikeLike