943,522 Members | Top Members by Rank

Jun 5th, 2009
0

Problem sending the SOAP request message to weblogic session web service

Expand Post »
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:
XML Syntax (Toggle Plain Text)
  1. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:SecurityToken xmlns:ns1="http://www.bea.com/wsdl/wlcp/wlng/session_manager/service"><username>sdpai</username><password>sdp</password></ns1:SecurityToken></soapenv:Header><soapenv:Body><ns2:getSession xmlns:ns2="http://www.bea.com/wsdl/wlcp/wlng/session_manager/service"><aName>TextMode</aName></ns2:getSession></soapenv:Body></soapenv:Envelope>

and the error I am getting is:

RSS, Web Services and SOAP Syntax (Toggle Plain Text)
  1. javax.xml.soap.SOAPException: No Security header in message but required by policy.
  2.  
  3. at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:194)
  4.  
  5. at org.apache.axis2.saaj.SOAPConnectionImpl.call(SOAPConnectionImpl.java:130)
  6.  
  7. at test.SOARequest.main(SOARequest.java:101)
  8.  
  9. Caused by: org.apache.axis2.AxisFault: No Security header in message but required by policy.
  10.  
  11. at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
  12.  
  13. at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
  14.  
  15. at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
  16.  
  17. at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
  18.  
  19. at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
  20.  
  21. at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:188)
  22.  
  23. ... 2 more


My Code is:
Java Syntax (Toggle Plain Text)
  1. SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
  2. SOAPConnection connection = sfc.createConnection();
  3. MessageFactory mf = MessageFactory.newInstance();
  4. SOAPMessage sm = mf.createMessage();
  5. SOAPPart soapPart = sm.getSOAPPart();
  6. SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
  7. SOAPHeader soapHeader = soapEnvelope.getHeader();
  8. SOAPHeaderElement headerElement = soapHeader
  9. .addHeaderElement(soapEnvelope
  10. .createName("SecurityToken", "ns1",
  11. [url]http://www.bea.com/wsdl/wlcp/wlng/session_manager/service));[/url]
  12. QName qn1 = new QName("username");
  13. SOAPElement quotation1 = headerElement.addChildElement(qn1);
  14. quotation1.addTextNode("XXX");
  15. QName qn2 = new QName("password");
  16. SOAPElement quotation2 = headerElement.addChildElement(qn2);
  17. quotation2.addTextNode("XXX");
  18. SOAPBody sb = sm.getSOAPBody();
  19. // sh.detachNode();
  20. QName bodyName = new QName(
  21. [url]http://www.bea.com/wsdl/wlcp/wlng/session_manager/service[/url],
  22. "getSession", "ns2");
  23. SOAPBodyElement bodyElement = sb.addBodyElement(bodyName);
  24. QName qn = new QName("aName");
  25. SOAPElement quotation = bodyElement.addChildElement(qn);
  26. quotation.addTextNode("TextMode");
  27. sm
  28. .setContentDescription("This is the request message for getting session ID");
  29. System.out.println("\n Soap Request:\n");
  30. sm.writeTo(System.out);
  31. System.out.println();
  32. System.out.println("My SOAP Message description is: "
  33. + sm.getContentDescription());
  34. URL endpoint = new URL(
  35. [url]http://localhost:8001/session_manager/SessionManager);[/url]
  36. SOAPMessage response = connection.call(sm, endpoint);
  37. System.out.println(response);
  38. System.out.println(response.getContentDescription());

Though my soap message have the header information, error says it doesnt have. please help me with this.
Last edited by peter_budo; Jun 5th, 2009 at 8:01 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
naveenduttvyas is offline Offline
1 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in RSS, Web Services and SOAP Forum Timeline: How do I set soap:header on my server?
Next Thread in RSS, Web Services and SOAP Forum Timeline: URL-Based API Key Restriction: How does validation works?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC