locked
Unexpected Error RRS feed

  • Question

  •  

    Hi all,

     

    I am trying to add an attribute to main form of an entity from an external aspx page. For that I am using ExportXmlRequest and ExportXmlResponse.

     

    My code is like this:

     

     

    CrmAuthenticationToken token = new CrmAuthenticationToken();
    token.AuthenticationType = 0;
    token.OrganizationName = "AdventureWorksCycle";
     CrmService service = new CrmService();
    service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
    service.CrmAuthenticationTokenValue = token;
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;
    ExportXmlRequest exportRequest = new ExportXmlRequest();

    // Define the entities to retrieve, in this case accounts and contacts.
    // The XML format must match this and the empty "nodes" node is required.
    exportRequest.ParameterXml = @"<importexportxml>
    <entities>
       <entity>account</entity>
    </entities>
    <nodes> 
       <node>templates</node>
    </nodes>
    <securityroles/>   
    <settings>
       <setting>marketing</setting>
    </settings>
    <workflows/>
    </importexportxml>";
    try

    {
    ExportXmlResponse entities = (ExportXmlResponse)service.Execute(exportRequest);

    }

    catch

    {

    Label2.Text = ex.Detail.InnerText.ToString();

    }

     

    When I run this code ExportXmlResponse is giving rise to a SoapException. The details of which are given below:

     

    0x80040216 An unexpected error occurred. Platform

     

    Kindly tell me what might be the problem 

     

    Friday, November 28, 2008 6:44 AM

Answers

  • Hi,

    *) Please correct this line :
    token.OrganizationName = "AdventureWorksCycle"; to the proper organization name. In example : token.OrganizationName = "MyOrganization";

    *) Please correct this line
    service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";

    into this line for example :
    service.Url = "http:/localhost:5555/mscrmservices/2007/crmservice.asmx";

    *) Please make sure that you run this code under a system user account who has System Administrator role for testing purposes in order to eliminate  permission issue

    *) Please catch the SoapException and refer to the soapExceptionObject.Detail.InnerText for the details of error messages.


            public static void Test()
            {
                try
                {
                    // Set up the CRM Service.
                    CrmAuthenticationToken token = new CrmAuthenticationToken();
                    // You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
                    token.AuthenticationType = 0;
                    token.OrganizationName = "MyOrganization";

                    CrmService service = new CrmService();
                    service.Url = "http://MyServer:5555/mscrmservices/2007/crmservice.asmx";
                    service.CrmAuthenticationTokenValue = token;
                    service.Credentials = System.Net.CredentialCache.DefaultCredentials;


                    // Create the request.
                    ExportXmlRequest exportRequest = new ExportXmlRequest();

                    // Define the entities to retrieve, in this case accounts and contacts.
                    // The XML format must match this and the empty "nodes" node is required.
                    exportRequest.ParameterXml = @"<importexportxml>
                    <entities>
                       <entity>accounta</entity>
                    </entities>
                    <nodes> 
                       <node>templates</node>
                    </nodes>
                    <securityroles/>   
                    <settings>
                       <setting>marketing</setting>
                    </settings>
                    <workflows/>
                    </importexportxml>";

                    // Execute the request.
                    ExportXmlResponse entities = (ExportXmlResponse)service.Execute(exportRequest);
                }
                catch (System.Web.Services.Protocols.SoapException se)
                {
                    Console.WriteLine(se.Detail.InnerText);

                    throw se;
                }

            }

    Regards,

    hadi teo.
    Friday, November 28, 2008 2:40 PM

All replies

  • I think you'll need to enable tracing on the CRM server (http://support.microsoft.com/default.aspx/kb/907490) to diagnose this. I expect the problem is somewhere in the ParameterXml
    Friday, November 28, 2008 11:48 AM
    Moderator
  • Hi David is there any alternative way of tracing the error as I dont have access to CRM server and cant make changes to its registry. I am connecting to server using a web client.

     

    Friday, November 28, 2008 1:00 PM
  • Hi,

    *) Please correct this line :
    token.OrganizationName = "AdventureWorksCycle"; to the proper organization name. In example : token.OrganizationName = "MyOrganization";

    *) Please correct this line
    service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";

    into this line for example :
    service.Url = "http:/localhost:5555/mscrmservices/2007/crmservice.asmx";

    *) Please make sure that you run this code under a system user account who has System Administrator role for testing purposes in order to eliminate  permission issue

    *) Please catch the SoapException and refer to the soapExceptionObject.Detail.InnerText for the details of error messages.


            public static void Test()
            {
                try
                {
                    // Set up the CRM Service.
                    CrmAuthenticationToken token = new CrmAuthenticationToken();
                    // You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
                    token.AuthenticationType = 0;
                    token.OrganizationName = "MyOrganization";

                    CrmService service = new CrmService();
                    service.Url = "http://MyServer:5555/mscrmservices/2007/crmservice.asmx";
                    service.CrmAuthenticationTokenValue = token;
                    service.Credentials = System.Net.CredentialCache.DefaultCredentials;


                    // Create the request.
                    ExportXmlRequest exportRequest = new ExportXmlRequest();

                    // Define the entities to retrieve, in this case accounts and contacts.
                    // The XML format must match this and the empty "nodes" node is required.
                    exportRequest.ParameterXml = @"<importexportxml>
                    <entities>
                       <entity>accounta</entity>
                    </entities>
                    <nodes> 
                       <node>templates</node>
                    </nodes>
                    <securityroles/>   
                    <settings>
                       <setting>marketing</setting>
                    </settings>
                    <workflows/>
                    </importexportxml>";

                    // Execute the request.
                    ExportXmlResponse entities = (ExportXmlResponse)service.Execute(exportRequest);
                }
                catch (System.Web.Services.Protocols.SoapException se)
                {
                    Console.WriteLine(se.Detail.InnerText);

                    throw se;
                }

            }

    Regards,

    hadi teo.
    Friday, November 28, 2008 2:40 PM
  • Thanks for the reply hadi teo .. Will check that out and let you know about the progress. 

     

    Monday, December 1, 2008 7:12 AM