Export (0) Print
Expand All

LogicalMethodInfo Class

Represents the attributes and metadata for an XML Web service method. This class cannot be inherited.

For a list of all members of this type, see LogicalMethodInfo Members.

System.Object
   System.Web.Services.Protocols.LogicalMethodInfo

[Visual Basic]
NotInheritable Public Class LogicalMethodInfo
[C#]
public sealed class LogicalMethodInfo
[C++]
public __gc __sealed class LogicalMethodInfo
[JScript]
public class LogicalMethodInfo

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

LogicalMethodInfo is used primarily by a SOAP extension to interrogate the details of the XML Web service method with which the SOAP extension is configured to run. Depending on how the SOAP extension is configured, it can find out details about the XML Web service method in the GetInitializer method of SoapExtension that takes a LogicalMethodInfo. The LogicalMethodInfo provides details such as the XML Web service method's parameters by accessing the Parameters property and any custom attributes applied to the XML Web service method using the GetCustomAttributes property.

For more details on SOAP extensions see the SoapExtension class or Altering the SOAP Message Using SOAP Extensions.

Example

[Visual Basic] 
' Process the SOAP message received and write to log file.
Public Overrides Sub ProcessMessage(message As SoapMessage)
   Select Case message.Stage
      Case SoapMessageStage.BeforeSerialize
      Case SoapMessageStage.AfterSerialize
         WriteOutput(CType(message, SoapServerMessage))
      Case SoapMessageStage.BeforeDeserialize
         WriteInput(CType(message, SoapServerMessage))
      Case SoapMessageStage.AfterDeserialize
      Case Else
            Throw New Exception("invalid stage")
   End Select
End Sub 'ProcessMessage

' Write the contents of the incoming SOAP message to the log file.
Public Sub WriteInput(message As SoapServerMessage)
   ' Utility method to copy the contents of one stream to another.
   Copy(oldStream, newStream)
   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.Name)
   myStreamWriter.WriteLine("The contents of the SOAP envelope are : ")
   myStreamWriter.Flush()
   newStream.Position = 0
   Copy(newStream, myFileStream)
   myFileStream.Close()
   newStream.Position = 0
End Sub 'WriteInput

' Write the contents of the outgoing SOAP message to the log file.
Public Sub WriteOutput(message As SoapServerMessage)
   newStream.Position = 0
   Dim myFileStream As New FileStream(filename, FileMode.Append, FileAccess.Write)
   Dim myStreamWriter As New StreamWriter(myFileStream)
   myStreamWriter.WriteLine("---------------------------------- Response at " + _
                             DateTime.Now)
   myStreamWriter.Flush()
   ' Utility method to copy the contents of one stream to another.
   Copy(newStream, myFileStream)
   myFileStream.Close()
   newStream.Position = 0
   Copy(newStream, oldStream)
End Sub 'WriteOutput

[C#] 
// Process the SOAP message received and write to log file.
public override void ProcessMessage(SoapMessage message) 
{
   switch (message.Stage) 
   {
      case SoapMessageStage.BeforeSerialize:
         break;
      case SoapMessageStage.AfterSerialize:
         WriteOutput((SoapServerMessage)message);
         break;
      case SoapMessageStage.BeforeDeserialize:
         WriteInput((SoapServerMessage)message);
         break;
      case SoapMessageStage.AfterDeserialize:
         break;
      default:
         throw new Exception("invalid stage");
   }
}

// Write the contents of the incoming SOAP message to the log file.
public void WriteInput(SoapServerMessage message)
{
   // Utility method to copy the contents of one stream to another. 
   Copy(oldStream, newStream);
   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.Name);
   myStreamWriter.WriteLine("The contents of the SOAP envelope are : ");
   myStreamWriter.Flush();
   newStream.Position = 0;
   Copy(newStream, myFileStream);
   myFileStream.Close();
   newStream.Position = 0;
}

// Write the contents of the outgoing SOAP message to the log file.
public void WriteOutput(SoapServerMessage message)
{
   newStream.Position = 0;
   FileStream myFileStream = new FileStream(filename, FileMode.Append, FileAccess.Write);
   StreamWriter myStreamWriter = new StreamWriter(myFileStream);
   myStreamWriter.WriteLine("---------------------------------- Response at " 
                                       + DateTime.Now);
   myStreamWriter.Flush();
   // Utility method to copy the contents of one stream to another. 
   Copy(newStream, myFileStream);
   myFileStream.Close();
   newStream.Position = 0;
   Copy(newStream, oldStream);
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.Services.Protocols

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Web.Services (in System.Web.Services.dll)

See Also

LogicalMethodInfo Members | System.Web.Services.Protocols Namespace | SoapExtension | GetInitializer | MethodInfo

Show:
© 2014 Microsoft