Link between WCF title and actions

I have a WCF service defined as follows:

[ServiceContract(Namespace = "http://AttributeServiceNameSpace", Name = "AttributeServiceName1")] public interface IHelloIndigoService1 { [OperationContract(Name="AttributeOperationName11", Action = "aaa2")] String HelloIndigo11(); [OperationContract(Name = "AttributeOperationName12", Action = "aaa1")] String HelloIndigo12(); } 

And I captured the HTTP message during the service call, as shown below.

POST http: //xxx/Service.svc/IHelloIndigoServiceAddress1 HTTP / 1.1

Content-Type: text / xml; encoding = UTF-8

SOAPAction: " aaa2 "

Host: shao-02.fareast.corp.microsoft.com

Content-Length: 162

Expect: 100-continue

Connection: Keep-Alive

 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <AttributeOperationName11 xmlns="http://AttributeServiceNameSpace"/> </s:Body> </s:Envelope> 

So, we can see that the name Action and Operation both exist in the SOAP message to call the service.

But I'm just wondering: Why do we need an Action and an Operation Name to identify one service method? Only one should be enough.

+4
source share
1 answer

You do not need Action and OperationName to identify the operation of the service. The operation name defines the structure (wrapper element name) of the SOAP message, but is not used to identify the operation. An action is used to identify an operation.

There are several non-standard SOAP parsers that use the operation name (root element) to identify the operation, but these parsers do not use the SOAP action.

Edit: Today I had a conversation with my colleague, and it looks like my previous answer is wrong. The true unique identifier for a message in SOAP is the SOAP Action + Root element. Thus, in this case, Action defines the SOAP Action and OperationName defines the name of the wrapper element (used as the root message element).

+2
source

Source: https://habr.com/ru/post/1398784/


All Articles