Does .net 2.0 web service always use soap on top of http?

I am doing research, and I downloaded a test application that calls the standard .asmx service. The service is called using a standard POST request. I was a little embarrassed because I thought .asmx services always use SOAP? Or is it possible to associate something recently introduced with HTTP (POST)?

+3
source share
3 answers

.NET Web-Services uses one protocol of your choice. By default, these are requests SOAPand are POSTallowed.

The standard help page created by .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>

You can also include a method GET:

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

This works with .NET 1.1

+1
source

, - ASMX SOAP. ScriptMethodAttribute, HTTP- -. .Net 3.5. :

[ScriptMethod(UseHttpGet = true)]
public string MyMethod()
{
   return "Hello World";
}
+1

SOAP is a standard that you can use. It is based on XML. If this is something simple than I use JSON. Web services are not limited to POST. You must use POST when starting Create / Update / Delete procedures, and you must use GET when starting data lookup procedures.

0
source

All Articles