gpt4 book ai didi

web-services - 如何通过 postman 发送SOAP请求

转载 作者:行者123 更新时间:2023-12-03 23:45:17 25 4
gpt4 key购买 nike

我正在尝试通过 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按钮可提供以下代码段:
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;
}

知道为什么吗?

最佳答案

最终结果很简单。我所做的只是浏览到Web服务,然后列出了可用的端点。然后单击GetCustomers链接。其中显示了所需XML的示例。然后,我将其用作Postman中请求正文的基础(您可能会注意到namespaces中的某些内容不同于我最初的尝试)。

单击Postman中的Generate Code按钮将产生以下内容:

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

<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>

哪个成功到达端点,但是这次正确填充了 GetCustomersRequest参数!

关于web-services - 如何通过 postman 发送SOAP请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39493927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com