Share via


SoapClient Class

Represents a client for sending SOAP messages using transport-independent protocols.

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

Usage

'Usage
Dim soapClient1 As New SoapClient()

Syntax

'Declaration
MustInherit Public Class SoapClient
    Inherits SoapSender
public abstract class SoapClient : SoapSender
public abstract ref class SoapClient : public SoapSender
public abstract class SoapClient extends SoapSender
public abstract class SoapClient extends SoapSender

Example

The following code example shows how to create a class that sends SOAP requests to a SoapService.

Class MyClient
   Inherits SoapClient
   
   Public Sub New(destination As Uri)
      MyBase.New(destination)
   End Sub 'New
   
   
   <SoapMethod("RequestResponseMethod")>  _
   Public Function RequestResponseMethod(envelope As SoapEnvelope) As SoapEnvelope
      Return MyBase.SendRequestResponse("RequestResponseMethod", envelope)
   End Function 'RequestResponseMethod
End Class 'MyClient
class MyClient : SoapClient
{
    public MyClient(Uri destination) : base(destination)
    {
    }

    [SoapMethod("RequestResponseMethod")]
    public SoapEnvelope RequestResponseMethod(SoapEnvelope envelope)
    {
        return base.SendRequestResponse("RequestResponseMethod",envelope);
    }
}

Remarks

When a class is derived from the SoapClient class, it is used to send SOAP request messages to a Web service and to receive SOAP response messages from that Web service using the SendOneWay and/or the SendRequestResponse methods. When SendOneWay is called, a SOAP request is sent to the Web service and the method does not wait for a response. In contrast, when SendRequestResponse is called, a SOAP request is sent to the Web service and the method does not return until a response is received. When a SOAP response message is required and you do not want to block the thread, use the .NET Framework asynchronous design pattern to send the SOAP message request using the BeginSendRequestResponse method.

SOAP messages can be constructed from a SoapEnvelope or a serializable object passed into the SendOneWay or SendRequestResponse method. Use a SoapEnvelope when you must add your own SOAP headers or access the SoapContext for a SOAP message. The SoapContext for a SoapEnvelope is accessed using the Context property. When a serializable object is used, it is serialized into 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.SoapSender
      Microsoft.Web.Services2.Messaging.SoapClient
         Microsoft.Web.Services2.Security.SecurityTokenServiceClient

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

SoapClient Members