简体   繁体   English

如何设置OperationContractAttribute.Action值?

[英]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. 我正在使用Visual Studio中的“添加服务引用”选项,以便使用第三方提供给我的WSDL文件创建代理类。 I got 2 versions of the WSDL - we'll call them "OLD" and "NEW". 我有两个版本的WSDL - 我们称之为“OLD”和“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. 尽管WSDL文件假设是相同的(新的文件有更新的方法版本),但在创建代理类时,我在OperationContractAttribute.Action中获得了不同的值。

In the OLD wsdl it looks like that: 在OLD wsdl中它看起来像这样:

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

In the new wsdl it looks like that: 在新的wsdl中它看起来像这样:

[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. 我无法从“Action”值取自哪里弄明白。

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 在旧的WSDL中,值是有效的,但在新的WSDL中是完全错误的,并且在尝试在WS中使用该服务时出现异常

When I look in the OLD wsdl file i can see a "soapAction" with the same value; 当我查看OLD wsdl文件时,我可以看到具有相同值的“soapAction”; 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中,有一个值与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 ) 在阅读了“Action”元素之后,我意识到我在NEW wsdl中看到的值是DEFAULT值(请参阅https://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute。行动(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 ? 现在我需要理解为什么在OLD wsdl文件中我们得到Action值是正确的(我猜测在正确操作下wsdl文件中定义的soapAction )并且在新wsdl中没有匹配和a是否填充了默认值?

ok found the problem! 确定发现了问题!

in the WSDL file there were multiple "Operation" with the same name 在WSDL文件中有多个具有相同名称的“Operation”

<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 “DoSomething”在这个例子中得到了2个版本1.1和2.2一旦我删除\\重命名所有重复操作(我有多个),“Action”值取自“soapAction”元素

hope this will help someone in the future ! 希望这将有助于未来的人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OperationContractAttribute的Action和ReplyAction属性可以相同吗? - Can the Action and ReplyAction property of OperationContractAttribute be the same? 如何在xmlSchemaType为“ dateTime”的“ XMLGregorianCalender”变量中仅设置年份值 - How to set only year value in “XMLGregorianCalender” variable whose xmlSchemaType is “dateTime” 如何在除&#39;&#39;之外的SOAPUI的请求xml中设置默认值 - How to set default value in request xml of SOAPUI other than '?' 如何使dotnet webservice在字符串值上设置minOccurs =“1” - How to make a dotnet webservice set minOccurs=“1” on a string value PHP SOAP WSDL如何使用相同的方法名称调用soap操作 - PHP SOAP WSDL How to call soap action with the same method name 如何在 WCF 服务中将 Action 设置为空白,因为客户端需要空白 SoapAction=&quot;&quot;? - How to make Action blank in WCF service, as client need blank SoapAction=""? 如何解决肥皂API的“找不到肥皂动作映射”? - How to solve the “cannot find soap action mapping for” soap api? 如何从wsdl文件中获取名称空间,方法和soap_action - How to get the namespace, method, soap_action from a wsdl file PHP Xpath:如何从 WSDL 上的任何方法获取操作 URL? - PHP Xpath: How to get the action URL from any method on a WSDL? 如何为savon版本2设置参数 - How to set arguments for savon version 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM