Search code examples
wsdlservice-referenceoperationcontract

How is the OperationContractAttribute.Action value is set?


I'm using the "Add Service Reference" option in Visual Studio in order to create a proxy class using a WSDL file given to me by a third party. I got 2 versions of the WSDL - we'll call them "OLD" and "NEW".

Even though the WSDL files suppose to be the same (the new one got updated methods version) , when creating the proxy classes I get a different values in the OperationContractAttribute.Action.

In the OLD wsdl it looks like that:

[System.ServiceModel.OperationContractAttribute(Action="http://webservices.amadeus.com/SATRQT_13_2_1A", ReplyAction="*")]

In the new wsdl it looks like that:

[System.ServiceModel.OperationContractAttribute(Action="http://xml.amadeus.com/AmadeusWebServicesPT/Air_MultiAvailabilityRequest", ReplyAction="http://xml.amadeus.com/AmadeusWebServicesPT/Air_MultiAvailabilityResponse")]

I can't figure it out from where the "Action" value is taken from.

In the old WSDL the value is valid , but in the new WSDL is completely wrong and I get an exception when trying to use the service in the WS

When I look in the OLD wsdl file i can see a "soapAction" with the same value; this seems to be where it's taken from. However in the NEW wsdl there is a value there exactly like in the OLD wsdl

<wsdl:operation name="Air_MultiAvailability">
  <soap:operation soapAction="http://webservices.amadeus.com/SATRQT_13_2_1A" />

Can anyone direct to me to the right place?

Update

After reading some more on the "Action" element I realized that the value that I see in the NEW wsdl is the DEFAULT value (see https://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.action(v=vs.110).aspx)

Now I need to understand WHY in the OLD wsdl file we get the Action value to be the correct one (I'm guessing from the soapAction defined in the wsdl file under the correct operation) and in the NEW wsdl there is no match and a default value is populated ?


Solution

  • ok found the problem!

    in the WSDL file there were multiple "Operation" with the same name

    <wsdl:portType name="WebServices"> 
      <wsdl:operation name="DoSomething">
          <wsdl:input message="ns:DoSomething_1_1" />
          <wsdl:output message="ns:DoSomething_1_1" />
        </wsdl:operation>
        <wsdl:operation name="DoSomething">
          <wsdl:input message="ns:DoSomething_2_2" />
          <wsdl:output message="ns:DoSomething_2_2" />
        </wsdl:operation>
      </wsdl:portType>
    
    <wsdl:binding type="ns:WebServices" name="WebServicesBinding">
        <wsdl:operation name="DoSomething">
          <soap:operation soapAction="http://webservices.my.com/DoSomething_1_1" />
        </wsdl:operation>
        <wsdl:operation name="DoSomething">
          <soap:operation soapAction="http://webservices.my.com/DoSomething_2_2" />
        </wsdl:operation>
    </wsdl:binding>
    

    the "DoSomething" got 2 version in this example 1.1 and 2.2 once i deleted\renamed ALL duplicated operations (i had multiple of them) the "Action" value was taken from the "soapAction" element

    hope this will help someone in the future !