SoapMessage Classe

Definizione

Rappresenta i dati di una richiesta o di una risposta SOAP in un oggetto SoapMessageStage specifico.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
Ereditarietà
SoapMessage
Derivato

Esempi

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

Commenti

L'utilizzo principale della SoapMessage classe è per le estensioni SOAP, che rappresentano i dati in una richiesta SOAP o una risposta SOAP.The primary use of the SoapMessage class is for SOAP extensions, representing the data in a SOAP request or SOAP response. Quando viene ProcessMessage chiamato il metodo, un SoapExtension oggetto riceve SoapMessage un oggetto SoapMessageStagea ogni.When the ProcessMessage method is called, a SoapExtension receives a SoapMessage at each SoapMessageStage. È l'estensione SOAP specifica a scegliere la modalità di elaborazione SoapMessagedi.It is up to the particular SOAP extension to choose how to process the SoapMessage. Le estensioni SOAP comuni includono la crittografia e la compressione.Common SOAP extensions include encryption and compression.

Le estensioni SOAP possono essere applicate a un metodo di servizio Web XML creato mediante ASP.NET o a un client di servizi Web XML.SOAP extensions can be applied to either or both an XML Web service method created using ASP.NET or an XML Web service client. Quando un'estensione SOAP viene applicata a un metodo di servizio Web XML, ProcessMessage il metodo riceve un'istanza SoapServerMessagedi che deriva da SoapMessage.When a SOAP extension is applied to an XML Web service method, the ProcessMessage method receives an instance of SoapServerMessage, which derives from SoapMessage. Analogamente, quando un'estensione SOAP viene applicata a un client di servizi Web ProcessMessage XML, riceve un' SoapClientMessageistanza di.Likewise, when a SOAP extension is applied to an XML Web service client, ProcessMessage receives an instance of SoapClientMessage.

Proprietà

Action

Quando se ne esegue l'override in una classe derivata, ottiene il campo di intestazione della richiesta HTTP SOAPAction per la richiesta o la risposta SOAP.When overridden in a derived class, gets the SOAPAction HTTP request header field for the SOAP request or SOAP response.

ContentEncoding

Ottiene o imposta i contenuti dell'intestazione HTTP Content-Encoding.Gets or sets the contents of the Content-Encoding HTTP header.

ContentType

Ottiene o imposta il Content-Type HTTP della richiesta SOAP o della risposta SOAP.Gets or sets the HTTP Content-Type of the SOAP request or SOAP response.

Exception

Ottiene l'oggetto SoapException dalla chiamata al metodo di servizio Web XML.Gets the SoapException from the call to the XML Web service method.

Headers

Insieme di intestazioni SOAP applicato alla richiesta o alla risposta SOAP corrente.A collection of the SOAP headers applied to the current SOAP request or SOAP response.

MethodInfo

Quando se ne esegue l'override in una classe derivata, ottiene una rappresentazione del prototipo di metodo per il metodo di servizio Web XML per cui può essere utilizzata la richiesta SOAP.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

Ottiene un valore che indica la proprietà OneWay dell'attributo SoapDocumentMethodAttribute o SoapRpcMethodAttribute applicato al metodo di servizio Web XML.Gets a value indicating the OneWay property of either the SoapDocumentMethodAttribute or the SoapRpcMethodAttribute attribute applied to the XML Web service method.

SoapVersion

Ottiene la versione del protocollo SOAP utilizzato per comunicare con il servizio Web XML.Gets the version of the SOAP protocol used to communicate with the XML Web service.

Stage

Ottiene l'oggetto SoapMessageStage di SoapMessage.Gets the SoapMessageStage of the SoapMessage.

Stream

Ottiene i dati che rappresentano la richiesta o la risposta SOAP in forma di Stream.Gets the data representing the SOAP request or SOAP response in the form of a Stream.

Url

Quando se ne effettua l'override in una classe derivata, ottiene l'URL di base del servizio Web XML.When overridden in a derived class, gets the base URL of the XML Web service.

Metodi

EnsureInStage()

Quando se ne esegue l'override in una classe derivata, asserisce che l'oggetto SoapMessageStage corrente corrisponde a una fase in cui i parametri in sono disponibili.When overridden in a derived class, asserts that the current SoapMessageStage is a stage where in parameters are available.

EnsureOutStage()

Quando se ne esegue l'override in una classe derivata, asserisce che l'oggetto SoapMessageStage corrente corrisponde a una fase in cui i parametri out sono disponibili.When overridden in a derived class, asserts that the current SoapMessageStage stage is a stage where out parameters are available.

EnsureStage(SoapMessageStage)

Assicura che la fase SoapMessageStage della chiamata al metodo del servizio Web XML corrisponda alla fase o alle fasi passate.Ensures that the SoapMessageStage of the call to the XML Web service method is the stage or stages passed in. Quando si verifica una mancanza di corrispondenza, viene generata un'eccezione.If the current processing stage is not one of the stages passed in, an exception is thrown.

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Ereditato da Object)
GetInParameterValue(Int32)

Ottiene i parametri passati al metodo di servizio Web XML in corrispondenza dell'indice specificato.Gets the parameter passed into the XML Web service method at the specified index.

GetOutParameterValue(Int32)

Ottiene i parametri out passati al metodo di servizio Web in corrispondenza dell'indice specificato.Gets the out parameter passed into the XML Web service method at the specified index.

GetReturnValue()

Ottiene il valore restituito di un metodo di servizio Web XML.Gets the return value of an XML Web service method.

GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Ereditato da Object)

Si applica a