反序列化操作“queryAll”消息的回复消息正文时出错:

Posted

技术标签:

【中文标题】反序列化操作“queryAll”消息的回复消息正文时出错:【英文标题】:Error in deserializing body of reply message for operation 'queryAll' Message: 【发布时间】:2021-09-10 07:00:59 【问题描述】:

这是我的整个 CSharp 代码,代码的最后一行收到了错误消息。

  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',

命名空间 SalesforceTest [捆绑] 公共类 OL_InventorySteps 公共流 XmlWriter 获取;私人套装;

    [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);

    这是 Xml 肥皂响应

    肥皂环境:身体 真的 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX姓名> 美国已关闭零售回购XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX姓名> 美国打开零售回购 2 正文> 信封>

【问题讨论】:

【参考方案1】:

soapenv:Header 和 soapenv:Body 缺少开始标记

【讨论】:

嗨 Arun Kumar,我更新了帖子并且确实有soapenv:Header 和soapenv:Body。 请查看以下帖子,因为它与您的问题有关***.com/questions/52775320/…

以上是关于反序列化操作“queryAll”消息的回复消息正文时出错:的主要内容,如果未能解决你的问题,请参考以下文章

如何从 C++ 中的套接字中的线格式反序列化 int

Kafka消息序列化和反序列化

在android studio中反序列化操作wcf的请求消息体时出错

Kafka 消息序列化和反序列化(上)

如何使用 DataContractSerializer 从文件中反序列化 WCF 肥皂响应消息?

使用 XmlDictionaryReader 反序列化肥皂消息