locked
Reading from ResponseXML SOAP to Xrm Page RRS feed

  • Question

  • Hello There,

    So today i started to work on SOAP concepts. i was working on this example where based on GUID of contact we retrieve all its details.

    function readme(){
    var xml = "" + 
    "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><request i:type=\"a:RetrieveRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\"><a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\"><a:KeyValuePairOfstringanyType><b:key>Target</b:key><b:value i:type=\"a:EntityReference\"><a:Id>604e43ed-7d63-e411-88fc-9cb6548d72f4</a:Id><a:LogicalName>contact</a:LogicalName><a:Name i:nil=\"true\"/></b:value></a:KeyValuePairOfstringanyType><a:KeyValuePairOfstringanyType><b:key>ColumnSet</b:key><b:value i:type=\"a:ColumnSet\"><a:AllColumns>true</a:AllColumns><a:Columns xmlns:c=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"/></b:value></a:KeyValuePairOfstringanyType></a:Parameters><a:RequestId i:nil=\"true\"/><a:RequestName>Retrieve</a:RequestName></request></Execute></s:Body></s:Envelope>" + 
    "";
    
    //var xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    //var xmlHttpRequest  = new ActiveXObject("Msxml2.XMLHTTP");
    
    if (window.XMLHttpRequest) {
          xmlHttpRequest=new XMLHttpRequest();                   // For all modern 
      } else if (window.ActiveXObject) {
         xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");  // For (older) IE
      }
    
    
    xmlHttpRequest.open("POST", Xrm.Page.context.getClientUrl() +"/XRMServices/2011/Organization.svc/web", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    
    var resultXml = xmlHttpRequest.responseText;
    alert(resultXml); //This printed out the response well.
    
    var resultXml1 = xmlHttpRequest.responseXML;
    
    alert("The real  value" +resultXml1);
    
    
    }

    for the above code i have Updated SOAPlogger. :)


    I have looked at responseXML and found it has all the feilds like lastname,address, and other stuff.

    what i need to know is , how do i get the data from the responseXML and show it on Xrm form (Ex: say Alert box of lastname)

    Any ideas? :)

    Guide me onto those resources please,

    Thank you


    Wednesday, November 26, 2014 11:51 AM

All replies

  • Please, post your XML here to help and guide you.

    http://www.w3schools.com/xml/xml_to_html.asp

    Wednesday, November 26, 2014 4:36 PM
  • Please, post your XML here to help and guide you.

    After posting my XML , here is the output from it.

    Target604e43ed-7d63-e411-88fc-9cb6548d72f4contactColumnSettrueRetrieve

    Guys i am stuck at this part. not able to understand. Give Examples for my scenario please

    var resultXml = xmlHttpRequest.responseText;

    alert(resultXml);

    var resultXml1 = xmlHttpRequest.responseXML;

    var do1 = resultXml1.selectSingleNode("//a:lastname").attributes[0].text;

    alert("The Do stuff is " +do1);

    here i get error for selectSingleNode - object does not support property.


    Thursday, November 27, 2014 5:25 AM