SoapService Class

Defines a Web service that is used to receive SOAP request messages and send SOAP response messages that are transport independent.

Namespace: Microsoft.Web.Services2.Messaging
Assembly: Microsoft.Web.Services2 (in microsoft.web.services2.dll)

Usage

'Usage
Dim soapService1 As New SoapService()

Syntax

'Declaration
Public Class SoapService
    Inherits SoapReceiver
public class SoapService : SoapReceiver
public ref class SoapService : public SoapReceiver
public class SoapService extends SoapReceiver
public class SoapService extends SoapReceiver

Example

The following code example shows how to create a class that handles the receipt of a SOAP request and returns a response.

Class MyService
   Inherits SoapService
   
   <SoapMethod("RequestResponseMethod")>  _
   Public Function RequestResponseMethod(envelope As SoapEnvelope) As SoapEnvelope
      Dim message As String = "Response from " + System.Net.Dns.GetHostName()
      Dim response As New SoapEnvelope()
      response.SetBodyObject(message)
      Return response
   End Function 'RequestResponseMethod
End Class 'MyService
class MyService : SoapService
{
    [SoapMethod("RequestResponseMethod")]
    public SoapEnvelope RequestResponseMethod(SoapEnvelope envelope)
    {
        string message = "Response from " + System.Net.Dns.GetHostName();
        SoapEnvelope response = new SoapEnvelope();
        response.SetBodyObject(message);
        return response;
    }
}

Remarks

For each SOAP operation in the Web service, add a method to the class and apply the SoapMethodAttribute attribute to the method. The method must have one parameter that is either a SoapEnvelope or an XML-serializable type, and it must return either a SoapEnvelope or an XML-serializable type. The SoapMethodAttribute allows you to specify the SOAP <Action> for the SOAP operation.

A SOAP message can be received as a SoapEnvelope or a serializable object passed into the method. Use a SoapEnvelope when you must add or access your own SOAP headers or manipulate the SoapContext for that SOAP message. The SoapContext for a SoapEnvelope is accessed using the Context property. When a serializable object is used, it is serialized into or from the <Body> element. Programmatic access to the SoapContext for the SOAP message is not available when a serializable object is used. Instead, configure the send policy, so that the WSE adds required elements to the SOAP message.

Inheritance Hierarchy

System.Object
   Microsoft.Web.Services2.Messaging.SoapPort
     Microsoft.Web.Services2.Messaging.SoapReceiver
      Microsoft.Web.Services2.Messaging.SoapService
         Microsoft.Web.Services2.Security.SecurityTokenService

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.

Platforms

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, and Windows 2000

Target Platforms

Windows 2000, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, Pocket PC, Windows CE, Smart Phone

See Also

Reference

Microsoft.Web.Services2.Messaging Namespace

Other Resources

SoapService Members