SoapSender Class

Provides the ability to transmit a SOAP message one way to a specified destination.

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

Usage

'Usage
Dim soapSender1 As New SoapSender()

Syntax

'Declaration
Public Class SoapSender
    Inherits SoapPort
public class SoapSender : SoapPort
public ref class SoapSender : public SoapPort
public class SoapSender extends SoapPort
public class SoapSender extends SoapPort

Example

The following code example shows how to use the SoapSender class to send a SOAP message with the TCP protocol to a destination specified in a text box named DestinationHostNameTextBox.

            Dim DestinationUri As New Uri("soap.tcp://" + DestinationHostNameTextBox.Text + "/MyReceiver")
            Dim Destination As New Addressing.EndpointReference(DestinationUri)
            Dim MySender As New SoapSender(Destination)
            Dim envelope As New SoapEnvelope()
            envelope.Context.Addressing.Action = New Addressing.Action("myReceiver")
            Dim body As XmlElement = envelope.CreateBody()
            body.InnerText = MessageTextBox.Text
            MySender.Destination = Destination
            MySender.Send(envelope)
        End If '</snippet5>
    End Sub 'SendButton_Click
End Class 'Form1

'
'   class MyReceiver : SoapReceiver
'   {
'       protected override void Receive( SoapEnvelope message )
'       {
'           TheForm.UpdateList(message.Body.InnerText);
'       }       
'
'       public Form1 TheForm;
'   }
'
'


Class MyReceiver
   Inherits SoapReceiver
   
   Protected Overloads Overrides Sub Receive(message As SoapEnvelope)
   End Sub 'Receive
End Class 'MyReceiver 'Processing of message goes here

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 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
Uri Destination = new Uri( "soap.tcp://" + DestinationHostNameTextBox.Text + "/MyReceiver");
SoapSender Sender = new SoapSender(Destination);
SoapEnvelope envelope = new SoapEnvelope();
envelope.Context.Addressing.Action = "myReceiver";
XmlElement body = envelope.CreateBody();
body.InnerText = MessageTextBox.Text;
Sender.Destination = Destination;
Sender.Send(envelope);

Remarks

The destination is a URI that is either specified in the constructor or assigned to the Destination property.

Inheritance Hierarchy

System.Object
   Microsoft.Web.Services2.Messaging.SoapPort
    Microsoft.Web.Services2.Messaging.SoapSender
       Microsoft.Web.Services2.Messaging.SoapClient

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

SoapSender Members