crm 2011 -- processing SOAP response


  • My SOAP request works great.  Below is my SOAP response.  How do i pull the address values out of it?

    <s:Envelope xmlns:s=\"\">
        <RetrieveResponse xmlns=\"\">
          <RetrieveResult xmlns:a=\"\" xmlns:i=\"\">
            <a:Attributes xmlns:b=\"\">
                <b:value i:type=\"c:string\" xmlns:c=\"\">123 Fake Street</b:value>
                <b:value i:type=\"c:string\" xmlns:c=\"\">123</b:value>
                <b:value i:type=\"c:string\" xmlns:c=\"\">Calgary</b:value>
                <b:value i:type=\"c:string\" xmlns:c=\"\">Canada</b:value>
                <b:value i:type=\"c:string\" xmlns:c=\"\">T2V1v2</b:value>
                <b:value i:type=\"c:string\" xmlns:c=\"\">AB</b:value>
                <b:value i:type=\"c:guid\" xmlns:c=\"\">c2ca7072-8b56-e111-b13c-782bcb2d6a7d</b:value>
            <a:EntityState i:nil=\"true\"/>
            <a:FormattedValues xmlns:b=\"\"/>
            <a:RelatedEntities xmlns:b=\"\"/>

    Below is sad attempt to try and get the address out of it. I can't get past "a:KeyValuePairOfstringanyType" because it can't find it.

    _getSuccess: function (responseXml, route) {
            switch (route) {
                case 'shipping':
                    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                    xmlDoc.async = "false";
                    x = xmlDoc.getElementsByTagName("a:KeyValuePairOfstringanyType");
                    for (i = 0; i < x.length; i++) {
                        var y = xmlDoc.getElementsByTagName("a:EntityReference");
                        for (j = 0; j < y.length; j++) {
                            if (y[j].getElementsByTagName("a:LogicalName")[0].text == "opportunity") {
                                var oppId = y[j].getElementsByTagName("a:Id")[0].text;
                                var serverUrl = Xrm.Page.context.getServerUrl();
                                // Cater for URL differences between on premise and online
                                if (serverUrl.match(/\/$/)) {
                                    serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                case 'setstate':

    Wednesday, 29 February, 2012 9:57 PM


  • Hi,

    As far as I understand \" is just a way to visualize ", so in reality there is no \ character in your response.

    Take a look at this project, it might be interesting for you:

    And on a side note AcitveXObject will work for IE only.

    • Marked as answer by FutureSteel Wednesday, 28 March, 2012 3:15 PM
    Thursday, 1 March, 2012 8:29 PM

All replies