0

Here is my entire CSharp code and the last line of the code is getting the error message.

  Here is the Error message back from running my test in Visual Studio.



Message: 
    System.ServiceModel.CommunicationException : Error in deserializing body of reply message for operation 'queryAll'.
      ----> System.InvalidOperationException : There is an error in XML document (1, 546).
      ----> System.InvalidOperationException : The specified type was not recognized: name='CARS_Vehicle__c',

namespace SalesforceTest { [Binding] public class OL_InventorySteps { public Stream XmlWriter { get; private set; }

    [Given(@"I log into Salesforce")]
    public async Task GivenILogIntoSalesforce()
    {
        MethodInfo method = typeof(XmlSerializer).GetMethod("set_Mode", 
        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
        method.Invoke(null, new object[] { 1 });

        SoapClient sc = new SoapClient();
        loginRequest req = new loginRequest();
        req.LoginScopeHeader = new LoginScopeHeader();
        string ServerURL;
        string SessionID;

        req.username = "xxxxxxxxxx@xxxxxxxxxxxx.com.mwqa";
        req.password = "xxxxxxxxxx";

        Console.WriteLine(sc.Endpoint.Address.Uri.ToString());

        loginResponse res = new loginResponse();

        try
        {
            res = await sc.loginAsync(null, req.username, req.password);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.StackTrace);
        }

        //Get the ServerURL from the Result
        ServerURL = res.result.serverUrl;
        SessionID = res.result.sessionId;

        queryAllRequest QA_Request = new queryAllRequest();
        SoapClient.EndpointConfiguration EP = new SoapClient.EndpointConfiguration();
        //EP.Equals(ServerURL);
        SoapClient Client = new SoapClient(EP, ServerURL);//, ServerURL);
        SessionHeader SH = new SessionHeader();
        QueryOptions QO = new QueryOptions();
        QO.batchSize = 50;
        QO.batchSizeSpecified = true;
        QA_Request.QueryOptions = QO;

        SH.sessionId = SessionID;
        QA_Request.SessionHeader = SH;

        QA_Request.queryString = "SELECT Account_Number__c, Name, 
        Origination_Country__c, Remarketing_Vehicle_Type__c, Remarketing_Status__c, 
        Hold_Reason__c FROM CARS_Vehicle__c WHERE Account_Number__c = \'xxxxxxxxxxxx\'";

        Console.WriteLine(Client.Endpoint.Address.Uri.ToString());
        IWebProxy proxy = WebRequest.GetSystemWebProxy();
        proxy.Credentials = CredentialCache.DefaultCredentials;
           
        var QA_Response = await Client.queryAllAsync(QA_Request.SessionHeader, 
        QA_Request.QueryOptions, QA_Request.queryString);
  1. Here is the Xml soap response

    <soapenv:Envelope <xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" <xmlns="urn:enterprise.soap.sforce.com" <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.enterprise.soap.sforce.com" soapenv:Header 16141 5000000 API REQUESTS </soapenv:Header> soapenv:Body true <sf:Id xsi:nil="true"/> <sf:Account_Number__c>XXXXXXXXXXXX</sf:Account_Number__c> <sf:Name>XXXXXXXXXXXXXXXXX</sf:Name> <sf:Origination_Country__c>USA</sf:Origination_Country__c> <sf:Remarketing_Status__c>Closed</sf:Remarketing_Status__c> <sf:Remarketing_Vehicle_Type__c>Retail Repo</sf:Remarketing_Vehicle_Type__c> <sf:Id xsi:nil="true"/> <sf:Account_Number__c>XXXXXXXXXXXXX</sf:Account_Number__c> <sf:Name>XXXXXXXXXXXXXXXXX</sf:Name> <sf:Origination_Country__c>USA</sf:Origination_Country__c> <sf:Remarketing_Status__c>Open</sf:Remarketing_Status__c> <sf:Remarketing_Vehicle_Type__c>Retail Repo</sf:Remarketing_Vehicle_Type__c> 2 </soapenv:Body> </soapenv:Envelope>

b2blj
  • 1
  • 1

1 Answers1

0

Opening tag is missing for soapenv:Header and soapenv:Body

Arun Kumar
  • 136
  • 5
  • Hi Arun Kumar, I updated the post and do have the soapenv:Header and soapenv:Body as well. – b2blj Jun 28 '21 at 03:27
  • Please look at the following post as it relates to your problem https://stackoverflow.com/questions/52775320/c-sharp-cant-deserialize-xml-containing-xsitype – Arun Kumar Jun 28 '21 at 04:01