SoapMessage クラス

定義

特定の SoapMessageStage の SOAP 要求または SOAP 応答のデータを表します。Represents the data in a SOAP request or SOAP response at a specific SoapMessageStage.

public ref class SoapMessage abstract
public abstract class SoapMessage
type SoapMessage = class
Public MustInherit Class SoapMessage
継承
SoapMessage
派生

// Process the SOAP message received and write to log file.
virtual void ProcessMessage( SoapMessage^ message ) override
{
   switch ( message->Stage )
   {
      case SoapMessageStage::BeforeSerialize:
         WriteOutputBeforeSerialize( message );
         break;
      case SoapMessageStage::AfterSerialize:
         WriteOutputAfterSerialize( message );
         break;
      case SoapMessageStage::BeforeDeserialize:
         WriteInputBeforeDeserialize( message );
         break;
      case SoapMessageStage::AfterDeserialize:
         WriteInputAfterDeserialize( message );
         break;
      default:
         throw gcnew Exception( "invalid stage" );
   }
}

// Write the contents of the outgoing SOAP message to the log file.
void WriteOutputBeforeSerialize( SoapMessage^ message )
{
   FileStream^ myFileStream =
      gcnew FileStream( filename, FileMode::Append, FileAccess::Write );
   StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream );
   myStreamWriter->WriteLine( "================================== Request at {0}",
      DateTime::Now );
   
   myStreamWriter->WriteLine(
      "The method that has been invoked is: " );
   myStreamWriter->WriteLine( "\t{0}", message->MethodInfo );

   myStreamWriter->WriteLine( "The contents of the SOAPAction HTTP header is:" );
   myStreamWriter->WriteLine( "\t{0}", message->Action );

   myStreamWriter->WriteLine( "The contents of HTTP Content-type header is:" );
   myStreamWriter->WriteLine( "\t{0}", message->ContentType );

   if ( message->OneWay )
   {
      myStreamWriter->WriteLine(
         "The method invoked on the client shall not wait"
         + " till the server finishes" );
   }
   else
   {
      myStreamWriter->WriteLine(
         "The method invoked on the client shall wait"
         + " till the server finishes" );
   }

   myStreamWriter->WriteLine(
      "The site where the XML Web service is available is:" );
   myStreamWriter->WriteLine( "\t{0}", message->Url );

   myStreamWriter->WriteLine( "The values of the in parameters are:" );
   myStreamWriter->WriteLine(
      "Value of first in parameter: {0}", message->GetInParameterValue( 0 ) );
   myStreamWriter->WriteLine(
      "Value of second in parameter: {0}", message->GetInParameterValue( 1 ) );

   myStreamWriter->WriteLine();
   myStreamWriter->Flush();
   myStreamWriter->Close();
   myFileStream->Close();
}

// Write the contents of the incoming SOAP message to the log file.
void WriteInputAfterDeserialize( SoapMessage^ message )
{
   FileStream^ myFileStream =
      gcnew FileStream( filename, FileMode::Append, FileAccess::Write );
   StreamWriter^ myStreamWriter = gcnew StreamWriter( myFileStream );
   myStreamWriter->WriteLine();
   
   myStreamWriter->WriteLine( "The values of the out parameter are:" );
   myStreamWriter->WriteLine(
      "The value of the out parameter is: {0}", message->GetOutParameterValue( 0 ) );

   myStreamWriter->WriteLine( "The values of the return parameter are:" );
   myStreamWriter->WriteLine(
      "The value of the return parameter is: {0}", message->GetReturnValue() );

   myStreamWriter->Flush();
   myStreamWriter->Close();
   myFileStream->Close();
}
// Process the SOAP message received and write to log file.
public override void ProcessMessage(SoapMessage message)
{
   switch (message.Stage)
   {
      case SoapMessageStage.BeforeSerialize:
         WriteOutputBeforeSerialize(message);
         break;
      case SoapMessageStage.AfterSerialize:
         WriteOutputAfterSerialize(message);
         break;
      case SoapMessageStage.BeforeDeserialize:
         WriteInputBeforeDeserialize(message);
         break;
      case SoapMessageStage.AfterDeserialize:
         WriteInputAfterDeserialize(message);
         break;
      default:
         throw new Exception("invalid stage");
   }
}

// Write the contents of the outgoing SOAP message to the log file.
public void WriteOutputBeforeSerialize(SoapMessage message)
{
   FileStream myFileStream =
      new FileStream(filename, FileMode.Append, FileAccess.Write);
   StreamWriter myStreamWriter = new StreamWriter(myFileStream);
   myStreamWriter.WriteLine("================================== Request at "
      + DateTime.Now);
   myStreamWriter.WriteLine("The method that has been invoked is: ");
   myStreamWriter.WriteLine("\t" + message.MethodInfo);
   myStreamWriter.WriteLine(
      "The contents of the SOAPAction HTTP header is:");
   myStreamWriter.WriteLine("\t" + message.Action);
   myStreamWriter.WriteLine("The contents of HTTP Content-type header is:");
   myStreamWriter.WriteLine("\t" + message.ContentType);
   if(message.OneWay)
      myStreamWriter.WriteLine(
         "The method invoked on the client shall not wait"
         + " till the server finishes");
   else
      myStreamWriter.WriteLine(
         "The method invoked on the client shall wait"
         + " till the server finishes");
   myStreamWriter.WriteLine(
      "The site where the XML Web service is available is:");
   myStreamWriter.WriteLine("\t" + message.Url);
   myStreamWriter.WriteLine("The values of the in parameters are:");
   myStreamWriter.WriteLine("Value of first in parameter: {0}",
      message.GetInParameterValue(0));
   myStreamWriter.WriteLine("Value of second in parameter: {0}",
      message.GetInParameterValue(1));
   myStreamWriter.WriteLine();
   myStreamWriter.Flush();
   myStreamWriter.Close();
   myFileStream.Close();
}

// Write the contents of the incoming SOAP message to the log file.
public void WriteInputAfterDeserialize(SoapMessage message)
{
   FileStream myFileStream =
      new FileStream(filename, FileMode.Append, FileAccess.Write);
   StreamWriter myStreamWriter = new StreamWriter(myFileStream);
   myStreamWriter.WriteLine();
   myStreamWriter.WriteLine("The values of the out parameter are:");
   myStreamWriter.WriteLine("The value of the out parameter is: {0}",
      message.GetOutParameterValue(0));
   myStreamWriter.WriteLine("The values of the return parameter are:");
   myStreamWriter.WriteLine("The value of the return parameter is: {0}",
      message.GetReturnValue());
   myStreamWriter.Flush();
   myStreamWriter.Close();
   myFileStream.Close();
}

' Process the SOAP message received and write to log file.
Public Overrides Sub ProcessMessage(message As SoapMessage)
   Select Case message.Stage
      Case SoapMessageStage.BeforeSerialize
         WriteOutputBeforeSerialize(message)
      Case SoapMessageStage.AfterSerialize
         WriteOutputAfterSerialize(message)
      Case SoapMessageStage.BeforeDeserialize
         WriteInputBeforeDeserialize(message)
      Case SoapMessageStage.AfterDeserialize
         WriteInputAfterDeserialize(message)
      Case Else
            Throw New Exception("invalid stage")
   End Select
End Sub

' Write the contents of the outgoing SOAP message to the log file.
Public Sub WriteOutputBeforeSerialize(message As SoapMessage)
   Dim myFileStream As New FileStream( _
      filename, FileMode.Append, FileAccess.Write)
   Dim myStreamWriter As New StreamWriter(myFileStream)
   myStreamWriter.WriteLine( _
      "================================== Request at " & _
      DateTime.Now)
   myStreamWriter.WriteLine("The method that has been invoked is: ")
   myStreamWriter.WriteLine(ControlChars.Tab & message.MethodInfo.ToString())
   myStreamWriter.WriteLine("The contents of the SOAPAction HTTP header is:")
   myStreamWriter.WriteLine(ControlChars.Tab & message.Action)
   myStreamWriter.WriteLine("The contents of HTTP Content-type header is:")
   myStreamWriter.WriteLine(ControlChars.Tab & message.ContentType)
   If message.OneWay Then
      myStreamWriter.WriteLine( _
         "The method invoked on the client shall not wait" & _
         " till the server finishes")
   Else
      myStreamWriter.WriteLine( _
         "The method invoked on the client shall wait" & _
         " till the server finishes")
   End If
   myStreamWriter.WriteLine( _
      "The site where the XML Web service is available is: ")
   myStreamWriter.WriteLine(ControlChars.Tab & message.Url)
   myStreamWriter.WriteLine("The values of the in parameters are:")
   myStreamWriter.WriteLine("Value of first in parameter: {0}", _
      message.GetInParameterValue(0))
   myStreamWriter.WriteLine("Value of second in parameter: {0}", _
      message.GetInParameterValue(1))
   myStreamWriter.WriteLine()
   myStreamWriter.Flush()
   myStreamWriter.Close()
   myFileStream.Close()
End Sub

' Write the contents of the incoming SOAP message to the log file.
Public Sub WriteInputAfterDeserialize(message As SoapMessage)
   Dim myFileStream As _
      New FileStream(filename, FileMode.Append, FileAccess.Write)
   Dim myStreamWriter As New StreamWriter(myFileStream)
   myStreamWriter.WriteLine()
   myStreamWriter.WriteLine("The values of the out parameter are:")
   myStreamWriter.WriteLine("The value of the out parameter is: {0}", _
      message.GetOutParameterValue(0))
   myStreamWriter.WriteLine("The values of the return parameter are:")
   myStreamWriter.WriteLine("The value of the return parameter is: {0}", _
      message.GetReturnValue())
   myStreamWriter.Flush()
   myStreamWriter.Close()
   myFileStream.Close()
End Sub

注釈

SoapMessageクラスの主な用途は、soap 要求または soap 応答のデータを表す soap 拡張機能です。The primary use of the SoapMessage class is for SOAP extensions, representing the data in a SOAP request or SOAP response. メソッドが呼び出されると、はSoapExtensionそれぞれSoapMessage SoapMessageStageでを受け取ります。 ProcessMessageWhen the ProcessMessage method is called, a SoapExtension receives a SoapMessage at each SoapMessageStage. を処理SoapMessageする方法を選択するには、特定の SOAP 拡張機能が必要です。It is up to the particular SOAP extension to choose how to process the SoapMessage. 一般的な SOAP 拡張機能には、暗号化と圧縮が含まれます。Common SOAP extensions include encryption and compression.

SOAP 拡張機能は、ASP.NET または XML Web サービスクライアントを使用して作成された XML Web サービスメソッドのいずれかまたは両方に適用できます。SOAP extensions can be applied to either or both an XML Web service method created using ASP.NET or an XML Web service client. SOAP 拡張機能が XML Web サービスメソッドに適用されると、 ProcessMessageメソッドは、からSoapMessage派生SoapServerMessageしたのインスタンスを受け取ります。When a SOAP extension is applied to an XML Web service method, the ProcessMessage method receives an instance of SoapServerMessage, which derives from SoapMessage. 同様に、SOAP 拡張機能が XML Web サービスクライアントに適用されるProcessMessageと、はのSoapClientMessageインスタンスを受け取ります。Likewise, when a SOAP extension is applied to an XML Web service client, ProcessMessage receives an instance of SoapClientMessage.

プロパティ

Action

派生クラスでオーバーライドされると、SOAP 要求または SOAP 応答の SOAPAction HTTP 要求ヘッダー フィールドを取得します。When overridden in a derived class, gets the SOAPAction HTTP request header field for the SOAP request or SOAP response.

ContentEncoding

Content-Encoding HTTP ヘッダーの内容を取得または設定します。Gets or sets the contents of the Content-Encoding HTTP header.

ContentType

SOAP 要求または SOAP 応答の HTTP Content-Type を取得または設定します。Gets or sets the HTTP Content-Type of the SOAP request or SOAP response.

Exception

XML Web サービス メソッドの呼び出しから SoapException を取得します。Gets the SoapException from the call to the XML Web service method.

Headers

現在の SOAP 要求または SOAP 応答に適用される SOAP ヘッダーのコレクション。A collection of the SOAP headers applied to the current SOAP request or SOAP response.

MethodInfo

派生クラスでオーバーライドされると、SOAP 要求の対象となる XML Web サービス メソッドのメソッド プロトタイプの表示を取得します。When overridden in a derived class, gets a representation of the method prototype for the XML Web service method for which the SOAP request is intended.

OneWay

XML Web サービス メソッドに適用される OneWay 属性または SoapDocumentMethodAttribute 属性の SoapRpcMethodAttribute プロパティを示す値を取得します。Gets a value indicating the OneWay property of either the SoapDocumentMethodAttribute or the SoapRpcMethodAttribute attribute applied to the XML Web service method.

SoapVersion

XML Web サービスとの通信に使用する SOAP プロトコルのバージョンを取得します。Gets the version of the SOAP protocol used to communicate with the XML Web service.

Stage

SoapMessageStageSoapMessage を取得します。Gets the SoapMessageStage of the SoapMessage.

Stream

Stream の形式で SOAP 要求または SOAP 応答を表しているデータを取得します。Gets the data representing the SOAP request or SOAP response in the form of a Stream.

Url

派生クラスでオーバーライドされると、XML Web サービスのベース URL を取得します。When overridden in a derived class, gets the base URL of the XML Web service.

メソッド

EnsureInStage()

派生クラスでオーバーライドされると、現在の SoapMessageStage は、in パラメーターが使用できる段階であることをアサートします。When overridden in a derived class, asserts that the current SoapMessageStage is a stage where in parameters are available.

EnsureOutStage()

派生クラスでオーバーライドされると、現在の SoapMessageStage 段階は out パラメーターが使用できる段階であることをアサートします。When overridden in a derived class, asserts that the current SoapMessageStage stage is a stage where out parameters are available.

EnsureStage(SoapMessageStage)

XML Web サービス メソッドの呼び出しの SoapMessageStage が渡された単数または複数の段階であることを確認します。Ensures that the SoapMessageStage of the call to the XML Web service method is the stage or stages passed in. 現在の処理段階が、渡された段階の 1 つではない場合は、例外がスローされます。If the current processing stage is not one of the stages passed in, an exception is thrown.

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判定します。Determines whether the specified object is equal to the current object.

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(継承元 Object)
GetInParameterValue(Int32)

指定されたインデックスで XML Web サービス メソッドに渡すパラメーターを取得します。Gets the parameter passed into the XML Web service method at the specified index.

GetOutParameterValue(Int32)

指定したインデックスで XML Web サービス メソッドに渡す out パラメーターを取得します。Gets the out parameter passed into the XML Web service method at the specified index.

GetReturnValue()

XML Web サービス メソッドの戻り値を取得します。Gets the return value of an XML Web service method.

GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(継承元 Object)
ToString()

現在のオブジェクトを表す string を返します。Returns a string that represents the current object.

(継承元 Object)

適用対象