【发布时间】:2017-01-22 11:10:36
【问题描述】:
我正在尝试通过 Postman chrome 扩展发送 SOAP 请求。我的请求正文在 Postman 中如下所示:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://partnerapi.somewhere.com/">
<soapenv:Body>
<ns1:GetCustomers>
<GetCustomersRequest>
<APIKey>SECRET</APIKey>
<PartnerKey></PartnerKey>
<SearchText></SearchText>
<ItemsPerPage>50</ItemsPerPage>
<PageNumber>1</PageNumber>
<Fields></Fields>
<OrderBy></OrderBy>
</GetCustomersRequest>
</ns1:GetCustomers>
</soapenv:Body>
</soapenv:Envelope>
编辑:
单击 Postman 中的Generate Code 按钮提供以下 sn-p:
POST /PartnerAPI.asmx HTTP/1.1
Host: localhost:3000
Content-Type: text/xml
SOAPAction: http://partnerapi.somewhere.com/GetCustomers
Cache-Control: no-cache
Postman-Token: 1af78251-9d36-0c94-d0e3-21f7e37ffc41
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://partnerapi.somewhere.com/">
<soapenv:Body>
<ns1:GetCustomers>
<GetCustomersRequest>
<APIKey>SECRET</APIKey>
<PartnerKey></PartnerKey>
<SearchText></SearchText>
<ItemsPerPage>50</ItemsPerPage>
<PageNumber>1</PageNumber>
<Fields></Fields>
<OrderBy></OrderBy>
</GetCustomersRequest>
</ns1:GetCustomers>
</soapenv:Body>
</soapenv:Envelope>
我在 Visual Studio 中运行了 Web 服务,并且我在正在命中的 Web 方法中设置了一个断点,因此请求到达了端点。
Web 方法签名如下所示:
[WebMethod]
public CustomersObject GetCustomers(RequestObjects.GetCustomersRequest GetCustomersRequest)
但GetCustomersRequest 参数始终为NULL。
GetCustomersRequest 类如下所示:
public class GetCustomersRequest {
public string APIKey;
public string PartnerKey;
public string SearchText;
public int ItemsPerPage = 50;
public int PageNumber = 1;
public string Fields;
public string OrderBy;
}
知道为什么吗?
【问题讨论】:
-
你展示了你的请求正文,但是你的请求的其余部分呢!在 Postman 中,如果您单击“生成代码”并将其粘贴到此处,可能会更有帮助。
-
@SiKing 我按照建议添加了“生成代码”按钮生成的 sn-p
标签: web-services soap postman