SOAP 1.2 POST请求在Postman中工作,而不在本地Visual Studio解决方案中工作-“根级别的数据无效”

问题描述

我有一个邮递员请求,它发出以下代码

using System;
using RestSharp;
namespace HelloWorldApplication {
  class HelloWorld {
    static void Main(string[] args) {
      var client = new RestClient("https://test-ewebservice.it.abc.com/CentralPaymentSite_WS/service.asmx?op=AuthCapRequestWithAddressAndName");
      client.Timeout = -1;
      var request = new RestRequest(Method.POST);
      request.AddHeader("Content-Type","application/soap+xml; charset=utf-8");
      request.AddHeader("Cookie","BIGipServer~UISS~test-ewebservice.it.abc.com_443_pool=2697198090.47873.0000");
      request.AddParameter("application/soap+xml; charset=utf-8","<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n  <soap12:Body>\n    <AuthCapRequestWithAddressAndName xmlns=\"webservice.it.abc.com\">\n      <MerchantID>AbcId</MerchantID>\n      <AuthorizationAmount>10.00</AuthorizationAmount>\n      <OnestepTranType>string</OnestepTranType>\n      <ApplicationIDPrimary>string</ApplicationIDPrimary>\n      <ReturnURL>http://nopcommerce.test/foo</ReturnURL>\n      <AuthorizationAttemptLimit>1</AuthorizationAttemptLimit>\n      <ApplicationIDSecondary>string</ApplicationIDSecondary>\n      <ApplicationStateData>string</ApplicationStateData>\n      <StyleSheetKey>string</StyleSheetKey>\n      <EmailAddressDeptContact>string</EmailAddressDeptContact>\n      <BillingAddress>string</BillingAddress>\n      <BillingCity>string</BillingCity>\n      <BillingState>string</BillingState>\n      <BillingZipCode>string</BillingZipCode>\n      <BillingCountry>string</BillingCountry>\n      <PostBackURL>http://nopcommerce.test/foo</PostBackURL>\n    </AuthCapRequestWithAddressAndName>\n  </soap12:Body>\n</soap12:Envelope>",ParameterType.RequestBody);
      IRestResponse response = client.Execute(request);
      Console.WriteLine(response.Content);
    }
  }
}

当我运行邮递员请求时,得到了预期的成功响应。当我在VS解决方案中运行代码时,出现以下错误

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">System.Web.Services.Protocols.soapException: Server was unable to process request. ---&gt; System.Xml.XmlException: Data at the root level is invalid. Line 1,position 1.

我在做什么错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)