如何解决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. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1,position 1.
我在做什么错了?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。