Compartir a través de


SoapMessage Clase

Definición

Representa los datos de una solicitud o una respuesta SOAP en una fase SoapMessageStage específica.

public ref class SoapMessage abstract
public abstract class SoapMessage
type SoapMessage = class
Public MustInherit Class SoapMessage
Herencia
SoapMessage
Derivado

Ejemplos

// 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

Comentarios

El uso principal de la SoapMessage clase es para las extensiones SOAP, que representan los datos de una solicitud SOAP o una respuesta SOAP. Cuando se llama al ProcessMessage método , recibe SoapExtension un SoapMessage objeto en cada SoapMessageStage. Es hasta la extensión SOAP concreta para elegir cómo procesar .SoapMessage Las extensiones SOAP comunes incluyen cifrado y compresión.

Las extensiones SOAP se pueden aplicar a un método de servicio web XML o ambos creados mediante ASP.NET o un cliente de servicio web XML. Cuando se aplica una extensión SOAP a un método de servicio web XML, el ProcessMessage método recibe una instancia de SoapServerMessage, que deriva de SoapMessage. Del mismo modo, cuando se aplica una extensión SOAP a un cliente de servicio web XML, ProcessMessage recibe una instancia de SoapClientMessage.

Propiedades

Action

Cuando se reemplaza en una clase derivada, obtiene el campo de encabezado de la solicitud HTTP del valor SOAPAction para la solicitud o respuesta SOAP.

ContentEncoding

Obtiene o establece el contenido del encabezado HTTP Content-Encoding.

ContentType

Obtiene o establece el Content-Type HTTP de la solicitud o respuesta de SOAP.

Exception

Obtiene SoapException a partir de la llamada al método de servicios Web XML.

Headers

Colección de encabezados SOAP aplicados a la solicitud o respuesta SOAP actual.

MethodInfo

Cuando se reemplaza en una clase derivada, obtiene una representación del prototipo de método del método de servicios Web XML al que se destina la solicitud SOAP.

OneWay

Obtiene un valor que indica la propiedad OneWay del atributo SoapDocumentMethodAttribute o del atributo SoapRpcMethodAttribute que se aplica al método de servicios Web XML.

SoapVersion

Obtiene la versión del protocolo SOAP utilizado para comunicar con el servicio Web XML.

Stage

Obtiene SoapMessageStage de SoapMessage.

Stream

Obtiene los datos que representan la solicitud o respuesta SOAP en forma de Stream.

Url

Cuando se reemplaza en una clase derivada, obtiene la dirección URL base del servicio Web XML.

Métodos

EnsureInStage()

Cuando se reemplaza en una clase derivada, declara que los parámetros in están disponibles en la fase SoapMessageStage actual.

EnsureOutStage()

Cuando se reemplaza en una clase derivada, declara que la fase SoapMessageStage actual es una fase en la que los parámetros out están disponibles.

EnsureStage(SoapMessageStage)

Garantiza que la fase SoapMessageStage de la llamada al método de servicios Web XML es la fase o fases que se han pasado. Si la fase de procesamiento actual no es ninguna de las fases que se han pasado, se producirá una excepción.

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetInParameterValue(Int32)

Obtiene el parámetro que se ha pasado al método de servicios Web XML en el índice especificado.

GetOutParameterValue(Int32)

Obtiene el parámetro out que se ha pasado al método de servicios Web XML en el índice especificado.

GetReturnValue()

Obtiene el valor devuelto por un método de servicios Web XML.

GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a