Error : Url does not contain MSCRMServices

I got this error while using Accessing Microsoft Dynamics CRM Web Services from onload of lead entity.

I used the sample given in SDK which calls the WhoAmI message with the Execute method to retrieve the ID of the current user.

Resolved the error by replacing the url

xmlhttp.open(‘POST’, SERVER_URL +’/mscrmservices/2007/crmservice.asmx’, false);

to

xmlhttp.open(“POST”,  “http://myServerName:Port/MSCrmServices/2007/CrmService.asmx”, false);

SERVER_URL  global variable actually returns

http://myServerName:Port/organizationname because of which we got the error.

Here is the final code that I used

//Define the soapBody for the WhoAmI request.

var soapBody = “<soap:Body><Execute xmlns=’http://schemas.microsoft.com/crm/2007/WebServices’><Request xsi:type=’WhoAmIRequest’ /></Execute></soap:Body>”;

//Wrap the Soap Body in a soap:Envelope.

var soapXml = “<soap:Envelope xmlns:soap=’http://schemas.xmlsoap.org/soap/envelope/&#8217; xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance&#8217; xmlns:xsd=’http://www.w3.org/2001/XMLSchema’>&#8221;;

soapXml += GenerateAuthenticationHeader();

soapXml += soapBody;

soapXml += “</soap:Envelope>”;

// Create the XMLHTTP object for the execute method.

var xmlhttp = new ActiveXObject(“Msxml2.XMLHTTP”);

xmlhttp.open(“POST”, http://d-3638:5555/MSCrmServices/2007/CrmService.asmx&#8221;, false);

xmlhttp.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);

xmlhttp.setRequestHeader(“SOAPAction”, http://schemas.microsoft.com/crm/2007/WebServices/Execute&#8221;);

//Send the XMLHTTP object.

xmlhttp.send(soapXml);

// Create an XML object to parse the results.

xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);

xmlDoc.async=false;

xmlDoc.loadXML(xmlhttp.responseXML.xml);

// Get the user’s ID.

var userid = xmlDoc.getElementsByTagName(“UserId”)[0].childNodes[0].nodeValue;

Bye..



Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “Error : Url does not contain MSCRMServices”

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s