Problem sending the SOAP request message to weblogic session web service

Please support our RSS, Web Services and SOAP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jun 2009
Posts: 1
Reputation: naveenduttvyas is an unknown quantity at this point 
Solved Threads: 0
naveenduttvyas naveenduttvyas is offline Offline
Newbie Poster

Problem sending the SOAP request message to weblogic session web service

 
0
  #1
Jun 5th, 2009
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:
  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:
  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC