gpt4 book ai didi

c# - .net 2.0 Web 服务是否始终使用 Soap over http?

转载 作者:行者123 更新时间:2023-11-30 17:17:41 25 4
gpt4 key购买 nike

我正在研究并下载了一个调用标准 .asmx 服务的测试应用程序。正在使用标准 POST 请求调用该服务。我有点困惑,因为我认为 .asmx 服务总是使用 SOAP?或者是最近引入的与 HTTP (POST) 通信的能力?

最佳答案

.NET Web 服务使用您选择的一种协议(protocol)。默认情况下是 SOAP,并且允许 POST 请求。

.NET 自动创建的标准帮助页面:

POST /demo/MSDN/PerfCounter.asmx HTTP/1.1
Connection: Keep-Alive
Content-Length: 150
Content-Type: text/xml
Host: localhost
User-Agent: MS Web Services Client Protocol 1.0.2204.19
SOAPAction: "http://tempuri.org/PerfCounters"

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body>
<PerfCounters xmlns="http://tempuri.org/"/>
</soap:Body>
</soap:Envelope>

您还可以启用 GET 方法:

<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>

这适用于 .NET 1.1

关于c# - .net 2.0 Web 服务是否始终使用 Soap over http?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6291554/

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