OperationContractAttribute.ReplyAction Właściwość

Definicja

Pobiera lub ustawia wartość akcji SOAP dla komunikatu odpowiedzi operacji.

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

Wartość właściwości

String

Wartość akcji SOAP dla wiadomości odpowiedzi.

Wyjątki

Przykłady

Poniższy przykład to usługa, która używa Action właściwości i ReplyAction do jawnego kontrolowania akcji PROTOKOŁU SOAP zarówno komunikatów wejściowych, jak i wyjściowych (lub odpowiedzi). Używa Name również właściwości do deklarowania nazwy operacji jako uwidocznionej w metadanych.

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

Uwagi

Oprócz określenia określonej wartości nagłówka akcji wiadomości odpowiedzi można również określić ciąg "*" (gwiazdka). Określenie gwiazdki w usłudze powoduje, że program WCF nie dodaje akcji odpowiedzi do wiadomości, co jest przydatne, jeśli programujesz bezpośrednio z komunikatami. Określenie gwiazdki w aplikacji klienckiej powoduje, że program WCF nie weryfikuje akcji odpowiedzi.

Dotyczy