locked
Permission Denied, xmlHttpRequest on CrmService RRS feed

  • Question

  • Hello everybody,

    I'm trying to implement my custom asp page on our new server. (it's running from ISV folder)

     

    I'm doing a xmlHttpRequest but it keeps giving me permission denied.

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttpRequest.Open("POST", "http://xx.xx.xx.xx:5555/MSCrmServices/2007/CrmServiceWsdl.aspx", false);

     


    Any help would be appreciated!

     

     

    Regars,

    Robin

    Monday, May 31, 2010 10:45 AM

Answers

  • I tried it already with the 'GenerateAuthenticationHeader()' method, and then it's saying object expceted or other errors..


    You'll have to provide an authentication header. The GenerateAuthenticationHeader() method is only available if your page runs inside CRM. Else you'll have to provide it yourself, see:

    http://msdn.microsoft.com/en-us/library/cc150838.aspx

    <soap:Header>
      <CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
       <AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
        0
       </AuthenticationType>
       <OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
        AdventureWorksCycle
       </OrganizationName>
       <CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
        00000000-0000-0000-0000-000000000000
       </CallerId>
      </CrmAuthenticationToken>
     </soap:Header>
    

    Wednesday, June 2, 2010 1:05 PM

All replies

  • Try to use
    xmlHttpRequest.Open("POST", "http://xx.xx.xx.xx:5555/MSCrmServices/2007/CrmService.asmx", false);

    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)
    Monday, May 31, 2010 10:57 AM
    Moderator
  • Yeah, that's the way we do it :-)

    And it results in Permission Denied..

     

    (don't mind my CrmServiceWsdl link in my post)

    Monday, May 31, 2010 11:00 AM
  • try if special user like domain\administrator  can login in?
    Monday, May 31, 2010 11:35 AM
  • when you send xml request you need to specify the user (authorized user) in that, what you are specifying there..

    for e.g. generally code looks like as follow for CRM 4.0,GenerateAuthenticationHeader() is CRM 4.0 function which generates authentication header for relevant CRM user..

     

    var xml = "" + 
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
     "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + 
     GenerateAuthenticationHeader() + 
     " <soap:Body>" + 
     " <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
     " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">" + 
     " <q1:EntityName>role</q1:EntityName>" + 
     " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
     " <q1:Attributes>" + 
     " <q1:Attribute>name</q1:Attribute>" + 
     " </q1:Attributes>" + 
     " </q1:ColumnSet>" + 
     " <q1:Distinct>false</q1:Distinct>" + 
     " <q1:LinkEntities>" + 
     " <q1:LinkEntity>" + 
     " <q1:LinkFromAttributeName>roleid</q1:LinkFromAttributeName>" + 
     " <q1:LinkFromEntityName>role</q1:LinkFromEntityName>" + 
     " <q1:LinkToEntityName>systemuserroles</q1:LinkToEntityName>" + 
     " <q1:LinkToAttributeName>roleid</q1:LinkToAttributeName>" + 
     " <q1:JoinOperator>Inner</q1:JoinOperator>" + 
     " <q1:LinkEntities>" + 
     " <q1:LinkEntity>" + 
     " <q1:LinkFromAttributeName>systemuserid</q1:LinkFromAttributeName>" + 
     " <q1:LinkFromEntityName>systemuserroles</q1:LinkFromEntityName>" + 
     " <q1:LinkToEntityName>systemuser</q1:LinkToEntityName>" + 
     " <q1:LinkToAttributeName>systemuserid</q1:LinkToAttributeName>" + 
     " <q1:JoinOperator>Inner</q1:JoinOperator>" + 
     " <q1:LinkCriteria>" + 
     " <q1:FilterOperator>And</q1:FilterOperator>" + 
     " <q1:Conditions>" + 
     " <q1:Condition>" + 
     " <q1:AttributeName>systemuserid</q1:AttributeName>" + 
     " <q1:Operator>EqualUserId</q1:Operator>" + 
     " </q1:Condition>" + 
     " </q1:Conditions>" + 
     " </q1:LinkCriteria>" + 
     " </q1:LinkEntity>" + 
     " </q1:LinkEntities>" + 
     " </q1:LinkEntity>" + 
     " </q1:LinkEntities>" + 
     " </query>" + 
     " </RetrieveMultiple>" + 
     " </soap:Body>" + 
     "</soap:Envelope>" + 
     ""; 
     
     var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
     
     xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); 
     xmlHttpRequest.setRequestHeader("SOAPAction"," http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple"); 
     xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); 
     xmlHttpRequest.setRequestHeader("Content-Length", xml.length); 
     xmlHttpRequest.send(xml); 
     
     var resultXml = xmlHttpRequest.responseXML; 
     

     

    Monday, May 31, 2010 11:47 AM
  • I tried it already with the 'GenerateAuthenticationHeader()' method, and then it's saying object expceted or other errors..
    Wednesday, June 2, 2010 7:46 AM
  • Hi rock,What is version of IE your using?Previosuly we face the same issue with IE6 & but same code works at IE7 above

    Thanks


    VenkataP
    Wednesday, June 2, 2010 7:52 AM
  • I tried it already with the 'GenerateAuthenticationHeader()' method, and then it's saying object expceted or other errors..


    You'll have to provide an authentication header. The GenerateAuthenticationHeader() method is only available if your page runs inside CRM. Else you'll have to provide it yourself, see:

    http://msdn.microsoft.com/en-us/library/cc150838.aspx

    <soap:Header>
      <CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
       <AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
        0
       </AuthenticationType>
       <OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
        AdventureWorksCycle
       </OrganizationName>
       <CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
        00000000-0000-0000-0000-000000000000
       </CallerId>
      </CrmAuthenticationToken>
     </soap:Header>
    

    Wednesday, June 2, 2010 1:05 PM