2 Replies - 2443 Views - Last Post: 10 September 2012 - 11:36 PM

#1 tabasum  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-September 12

consume soap request xml to get response in jsp

Posted 03 September 2012 - 04:06 AM

function makeSoapRequest(form){
      // create the payload of the SOAP request
      var soapData = '<?xml version="1.0" encoding="utf-8"?>' +
      '<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">'+
      ' <header xmlns=\"http://schemas.cordys.com/General/1.0/\">'+
     '</header>'+
       '<SOAP:Body>'+
         '<authenticateAgainstOID xmlns=\"http://schemas.cordys.com/OIDAuthentication">'+
          ' <stringParam>HEMANTS_MUM013</stringParam>'+
           '<stringParam1>TATA2012</stringParam1>'+
         '</authenticateAgainstOID>'+
      ' </SOAP:Body>'+
     '</SOAP:Envelope>';
            alert(soapData);

      try{
            netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
      }catch(e){
           // alert("Permission UniversalBrowserRead denied.");
      };

      try{ 
            if (window.XMLHttpRequest){ 
            req = new XMLHttpRequest(); 
      }else{ 
            req = new ActiveXObject("authenticateAgainstOID"); 
      } 
      }catch(e){ 
  
      };
 
      req.open("POST", "http://tmcrmappsqa.inservices.tatamotors.com/cordys/com.eibus.web.soap.Gateway.wcp?organization=o=B2C,cn=cordys,cn=cbop,o=tatamotors.com&SAMLart=MDFn+8e5dRDaRMRIwMY7nI84eEccbx+lIiUGdimp3m+PzJ5ZSdKFP54f", false);
      req.setRequestHeader("Content-Length", soapData.length);
      req.setRequestHeader("Content-Type", "text/xml");
      req.setRequestHeader("Soapaction", "http://tmcrmappsqa.inservices.tatamotors.com/cordys/com.eibus.web.soap.Gateway.wcp?organization=o=B2C,cn=cordys,cn=cbop,o=tatamotors.com&SAMLart=MDFn+8e5dRDaRMRIwMY7nI84eEccbx+lIiUGdimp3m+PzJ5ZSdKFP54f");
      req.send(soapData);
      
      document.getElementById('response').innerHTML = req.responseText;
             var xmlDocument1 = req.responseXML;
      parseXmlDocument(xmlDocument1);
}


function parseXmlDocument(docName){

      var xmlDoc = new ActiveXObject("authenticateAgainstOID");
      xmlDoc.async = "false";
      xmlDoc.load(docName);

      var token = xmlDoc.getElementByTagName("authenticateAgainstOID").text;
     

  for (var i=0; i < fullNodeList.length; i++)
  {
   var eachnode = new Option();
      eachnode.text = fullNodeList[i].childNodes[0].nodeValue;
     eachnode.value = fullNodeList[i].attributes[0].value;
   }
      alert(token);

};


can anyone suggest me the proper way to set the soap request to get the response.i have tried this way.

This post has been edited by macosxnerd101: 03 September 2012 - 05:11 AM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: consume soap request xml to get response in jsp

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2832
  • View blog
  • Posts: 12,000
  • Joined: 20-September 08

Re: consume soap request xml to get response in jsp

Posted 03 September 2012 - 04:57 AM

Not a Java question. You need Javascript
Was This Post Helpful? 0
  • +
  • -

#3 fahadcv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-September 12

Re: consume soap request xml to get response in jsp

Posted 10 September 2012 - 11:36 PM

Before reading the responseText from the Object of XMLHttpRequest OR ActiveXObject, we should check the readystate and status as in below code

req.onreadystatechange=function()
  {
	if (req.readyState==4 && req.status==200)
	{
		parseXmlDocument(req.responseText);
	}
  }


Also please note that checking the readystate and status is done in the onreadystatechange function.

Happy Coding!
Fahad
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1