ASP.NET Web应用程序创建的webservice接口如何在postman里测试调用
ASMX中的方法
启动项目浏览器展示的页面如下
点击ReceiveOrder,展示该方法的请求和响应示例
在postman中输入以下信息
选择raw--xml,粘贴浏览器中的SOAP1.1或者SOAP1.2中的请求示例
点击Send按钮发生请求
SOAP 1.1
以下是 SOAP 1.1 请求和响应示例。所显示的占位符需替换为实际值。
POST /WebService.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://server.webservice.example.com/ReceiveOrder" <?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> <ReceiveOrder xmlns="http://server.webservice.example.com"> <xmlString>string</xmlString> </ReceiveOrder> </soap:Body> </soap:Envelope>
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?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> <ReceiveOrderResponse xmlns="http://server.webservice.example.com"> <ReceiveOrderResult>string</ReceiveOrderResult> </ReceiveOrderResponse> </soap:Body> </soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /WebService.asmx HTTP/1.1 Host: localhost Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <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"> <soap12:Body> <ReceiveOrder xmlns="http://server.webservice.example.com"> <xmlString>string</xmlString> </ReceiveOrder> </soap12:Body> </soap12:Envelope>
HTTP/1.1 200 OK Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <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"> <soap12:Body> <ReceiveOrderResponse xmlns="http://server.webservice.example.com"> <ReceiveOrderResult>string</ReceiveOrderResult> </ReceiveOrderResponse> </soap12:Body> </soap12:Envelope>
HTTP POST
以下是 HTTP POST 请求和响应示例。所显示的占位符需替换为实际值。
POST /WebService.asmx/ReceiveOrder HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length
xmlString=string
HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://server.webservice.example.com">string</string>