1

OperationContract 属性中的 Action 和 ReplyAction 有什么用?

4

2 回答 2

5

Action 为您的服务方法定义了您的输入 uri,用于肥皂操作。

回复操作为您的服务方法定义输出 uri。

它们基本上用于为两者自定义 uri。见下文。

 [ServiceContract]
 public partial interface IServiceContract
 {
    [OperationContract(
            Action = "http://mynamspace/v1/IServiceContract/Input/ServiceMethod",
            ReplyAction = "http://mynamspace/v1/IServiceContract/Output/ServiceMethod")]
    SomeResponseType ServiceMethod(SomeRequestType x);

在您的 wsdl 中,您会看到

 <wsdl:portType name="IServiceContract">
    <wsdl:operation name="ServiceMethod">
    <wsdl:input wsaw:Action="http://mynamspace/v1/IServiceContract/Input/ServiceMethod" name="SomeRequestType" message="tns:SomeRequestType " /> 
    <wsdl:output wsaw:Action="http://mynamspace/v1/IServiceContract/Output/ServiceMethod" name="SomeResponseType" message="tns:SomeResponseType " /> 

有道理?

于 2010-04-04T20:00:30.497 回答
1

它用于WS寻址。

WS-Addressing 简介:http ://www.fpml.org/_wgmail/_bpwgmail/pdfdz3oYx1M9e.pdf http://www.w3.org/Submission/ws-addressing/

查看回复soap消息:http: //msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.action.aspx

于 2011-06-23T03:59:20.623 回答