c# - 如何在soap web services c#中请求并获取响应
问题描述
我有 .asmx url,我需要按订单号获取订单详细信息。
我的问题是,当我执行代码时,它会带回“ http://domain.co.za/services/portal.asmx?op=GetOrderDefinition ”的 html 设计而不填充响应。这是我的代码
var client = new RestClient("http://domain.co.za/services/portal.asmx?op=GetOrderDefinition");
var requests = new RestRequest(Method.GET);
client.Proxy = WebRequest.DefaultWebProxy;
client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
requests.AddHeader("Host", "test.lensportal.co.za");
requests.AddHeader("Content-Type", "text/xml; charset=utf-8");
requests.AddHeader("SOAPAction", "http://www.domain.co.za/GetOrderDefinition");
requests.AddParameter("{\r\n \"orderRef\": \"" + LabOrderReference + "\"\r\n}", RestSharp.ParameterType.RequestBody);
IRestResponse responses = client.Execute(requests);
链接“ http://domain.co.za/services/portal.asmx?op=GetOrderDefinition ”包含下面的示例,我需要在请求时传递“orderRef”并从订单详细信息中取回列表。请注意,该链接还具有 SOAP 1.1 响应设计,现在我只包含请求部分。
POST /services/portal.asmx HTTP/1.1
Host: test.lensportal.co.za
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.domain.co.za/GetOrderDefinition"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetOrderDefinition xmlns="http://www.domain.co.za">
<orderRef>string</orderRef>
</GetOrderDefinition>
</soap:Body>
</soap:Envelope>
解决方案
推荐阅读
- pytorch - 如何重用后向传递原语?
- python-3.x - 如何在 QTreeView 中为文件类型使用系统默认图标
- discord.js - 更改语音通道服务器区域不和谐 js
- kubernetes - 来自我们的 AKS 集群的间歇性响应;怀疑负载均衡器问题
- java - Eclipse Javafx 可运行 Jar
- sql - 寻找返回传递参数的最佳方法,以允许我在 SQL 中返回特定客户或所有客户
- html-email - 将带有链接的 HTML 电子邮件直接发送回应用程序,我们如何禁用以便“预览”或扫描不会点击这些链接?
- ruby-on-rails - graphql过滤单元测试
- javascript - 如何使输入->值->类型->搜索动态?
- javascript - 将文件的base64值发送到api