Sim*_*max 12 soap web-services postman
我正在尝试通过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>
Run Code Online (Sandbox Code Playgroud)
编辑:
单击Generate CodePostman中的按钮提供以下代码段:
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
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)
我有在Visual Studio中运行的Web服务,并且我在web方法中设置了一个断点,该断点正被命中,因此请求到达端点.
Web方法签名如下所示:
[WebMethod]
public CustomersObject GetCustomers(RequestObjects.GetCustomersRequest GetCustomersRequest)
Run Code Online (Sandbox Code Playgroud)
但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;
}
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?
Sim*_*max 13
事实证明最终是非常直截了当的.我所做的只是浏览到Web服务,然后列出可用的端点.然后点击GetCustomers链接.其中显示了所需XML的示例.然后我用它作为邮递员请求主体的基础(你可能会注意到一些namespaces与我原来的尝试不同).
单击Generate CodePostman中的按钮可生成以下内容:
POST /PartnerAPI.asmx HTTP/1.1
Host: localhost:53355
Content-Type: text/xml; charset=utf-8
SOAPAction: http://partnerapi.somewhere.com/GetCustomers
Cache-Control: no-cache
Postman-Token: 914d2152-9063-ff57-91a0-e567714c2d44
Run Code Online (Sandbox Code Playgroud)
<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>
<GetCustomers xmlns="http://partnerapi.somewhere.com/">
<GetCustomersRequest>
<APIKey>SECRET</APIKey>
<SearchText></SearchText>
<ItemsPerPage>10</ItemsPerPage>
<PageNumber>1</PageNumber>
<Fields></Fields>
<OrderBy></OrderBy>
</GetCustomersRequest>
</GetCustomers>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
哪个成功到达端点,但这次GetCustomersRequest参数填充正确!
| 归档时间: |
|
| 查看次数: |
53910 次 |
| 最近记录: |