OperationContractAttribute.ReplyAction Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the value of the SOAP action for the reply message of the operation.
public:
property System::String ^ ReplyAction { System::String ^ get(); void set(System::String ^ value); };
public string ReplyAction { get; set; }
member this.ReplyAction : string with get, set
Public Property ReplyAction As String
The value of the SOAP action for the reply message.
ReplyAction is null
.
The following example is a service that uses the Action and ReplyAction properties to explicitly control the SOAP actions of both the input and output (or reply) messages. It also uses the Name property to declare the name of the operation as exposed in metadata.
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Text;
namespace Microsoft.WCF.Documentation
{
[ServiceContract(Namespace="http://Microsoft.WCF.Documentation")]
public interface ISampleService{
[OperationContract(
Action="http://Microsoft.WCF.Documentation/OperationContractMethod",
Name="OCAMethod",
ReplyAction="http://Microsoft.WCF.Documentation/ResponseToOCAMethod"
)]
string SampleMethod(string msg);
[OperationContractAttribute(Action = "*")]
void UnrecognizedMessageHandler(Message msg);
}
class SampleService : ISampleService
{
public string SampleMethod(string msg)
{
Console.WriteLine("Called with: {0}", msg);
return "The service greets you: " + msg;
}
public void UnrecognizedMessageHandler(Message msg)
{
Console.WriteLine("Unrecognized message: " + msg.ToString());
}
}
}
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Text
Namespace Microsoft.WCF.Documentation
<ServiceContract(Namespace:="http://Microsoft.WCF.Documentation")> _
Public Interface ISampleService
<OperationContract(Action:="http://Microsoft.WCF.Documentation/OperationContractMethod", _
Name:="OCAMethod", ReplyAction:="http://Microsoft.WCF.Documentation/ResponseToOCAMethod")> _
Function SampleMethod(ByVal msg As String) As String
<OperationContractAttribute(Action := "*")> _
Sub UnrecognizedMessageHandler(ByVal msg As Message)
End Interface
Friend Class SampleService
Implements ISampleService
Public Function SampleMethod(ByVal msg As String) As String Implements ISampleService.SampleMethod
Console.WriteLine("Called with: {0}", msg)
Return "The service greets you: " & msg
End Function
Public Sub UnrecognizedMessageHandler(ByVal msg As Message) Implements ISampleService.UnrecognizedMessageHandler
Console.WriteLine("Unrecognized message: " & msg.ToString())
End Sub
End Class
End Namespace
In addition to specifying a particular value for the action header of the reply message, you can also specify the string "*" (an asterisk). Specifying an asterisk in the service instructs WCF not to add a reply action to the message, which is useful if you are programming against messages directly. Specifying an asterisk in a client application instructs WCF not to validate the reply action.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, 8 (package-provided) |
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: