axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Problem invoking the service method.
Date Fri, 05 Jun 2009 10:13:45 GMT
Hello Tenchnocrats,
I am getting the following error while invoking the "getSession" method of sessionmanager
webservice deployed in weblogic OCSG.
I have created a soap message properly but its giving error as "javax.xml.soap.SOAPException:
No Security header in message but required by policy."
The SOAP message created is by below code is:
"<soapenv:Envelope xmlns:soapenv=""><soapenv:Header><ns1:SecurityToken

and the error I am getting is:
javax.xml.soap.SOAPException: No Security header in message but required by policy.

at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(


at test.SOARequest.main(

Caused by: org.apache.axis2.AxisFault: No Security header in message but required by policy.

at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(

at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(

at org.apache.axis2.description.OutInAxisOperationClient.send(

at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(

at org.apache.axis2.client.OperationClient.execute(

at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(

... 2 more

My Code is:
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage sm = mf.createMessage();
SOAPPart soapPart = sm.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPHeader soapHeader = soapEnvelope.getHeader();
SOAPHeaderElement headerElement = soapHeader
.createName("SecurityToken", "ns1",;
QName qn1 = new QName("username");
SOAPElement quotation1 = headerElement.addChildElement(qn1);
QName qn2 = new QName("password");
SOAPElement quotation2 = headerElement.addChildElement(qn2);
SOAPBody sb = sm.getSOAPBody();
// sh.detachNode();
QName bodyName = new QName(,
"getSession", "ns2");
SOAPBodyElement bodyElement = sb.addBodyElement(bodyName);
QName qn = new QName("aName");
SOAPElement quotation = bodyElement.addChildElement(qn);
.setContentDescription("This is the request message for getting session ID");
System.out.println("\n Soap Request:\n");
System.out.println("My SOAP Message description is: "
+ sm.getContentDescription());
URL endpoint = new URL(
SOAPMessage response =, endpoint);

Though my soap message have the header information, error says it doesnt have. please help
me with this. 

This message is for the designated recipient only and may contain privileged, proprietary,
or otherwise private information.  If you have received it in error, please notify the sender
immediately and delete the original.  Any other use of the email by you is prohibited.

View raw message