I am trying to extract data from SOAP message header, using axis2 raw xml message receivers. My SOAP envelope look like :
<?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <tns:UserId xmlns:tns="http://www.mycompany.com/MyService">someUser</tns:UserId> </soapenv:Header> <soapenv:Body /> </soapenv:Envelope> Using the following code I am getting ns always null. What would be missing in this code ? Gul import org.apache.axiom.soap.SOAPHeader; import org.apache.axiom.soap.SOAPEnvelope; public OMElement getXXX(OMElement inputMsg) throws AxisFault { // This message doesn't have body. Get namespace prefix from the SOAP header // Do I need inputMsg as in parameter here ? MessageContext msgContext = MessageContext.getCurrentMessageContext(); String nsPrefix = null; SOAPEnvelope envelope = msgContext.getEnvelope(); // Envelope looks good... if (envelope != null) { SOAPHeader header = envelope.getHeader(); if (header != null) { // Header is good OMNamespace ns = header.findNamespace( "http://www.mycompany.com/MyService", null); if (ns != null) { // ns is ALWAYS null..Why ? nsPrefix = ns.getPrefix(); if (nsPrefix != null) { ... } } } } ... }
