In the past few years SOAP has emerged as one of the most widely used standards in distributed environments. Far beyond communicating with objects in remote leases, it may also define an extensible XML messaging framework to exchange XML messages between Internet objects. According to its definition, SOAP can be used with a variety of transport protocols such as HTTP, TCP, SMTP and even MSMQ.
The most popular implementations for the development of Web Services have been built on HTTP. In such an environment, however, it is very difficult to use many of the most attractive potentialities of Web Services since they need the asynchronous communication mechanisms found in TCP, SMTP or MSMQ. For this reason, any Web Services development technology should provide support so that the same logic of a Web Service might be consented by different communication protocols. Specifically, in the .NET environment some technologies like Web Services Enhancements (WSE) for Microsoft.NET and the recent Code Name Indigo have come out allowing for the development of Web Services over a variety of communication protocols, including TCP and the others.
The WSE is an Add-on to the .NET Framework. It provides additional Web Services support mostly for the various Web Services Architecture (WSA) specifications. This technology represents specific functionalities that will increase the Web Services potentialities. Based on standards, full interoperability is guaranteed among Web Services of high requirements. Actually, WSE 2.0 provides support for specifications like WS-Policy, WS-Security Policy and WS-Addressing among others implemented on WSE 1.0. Additionally, WSE 2.0 offers a rich messaging API to develop Web Services over other transports like TCP and recently over SMTP. In this article we explain the XML-Messaging capabilities of WSE 2.0 and we try to demonstrate how to use these potentialities to build XML-Based-Messaging applications.
XML messaging:
Besides the traditional way of communicating through HTTP, the WSE 2.0 provides additional communication protocols to interact either with Web Services like TCP and In-Process (client and server running in the same process).
The communication pattern is expressed by means of an URI that should correspond to the following syntax:

- Protocol_sch represents the protocol used for the communication with the Web Service.
- Port expresses the port where to send the messages.
- Path represents the localization of the resources that make up the Web Services inside a host.
An HTTP destination is represented by:
http://MyHost/MyPath.
In the case of TCP,
soap.tcp://MyHost/MyPath.
Lower level messaging
A distributed environment based on XML messaging is made up of objects that you/they send messages and objects that you/they receive messages. In this case, one is often made to think in terms of sender and receiver instead of client and server. Many times, client and server terms may be confusing in a model since some models like Publisher-Subscriber may represent more than a typical client-server model.
To send and receive SOAP messages, WSE 2.0 introduces the notion of SOAPSender and SOAPReceiver classes in order to build low level messaging applications. Flexibility and emphasis on XML messaging can be increased by these applications, although they require XML and SOAP skilled developers to work directly with SOAP messages.
In WSE 2.0 the SoapEnvelope class represents the content of a SOAP message. This class derives from XmlDocument and provides additional functionality to work with SOAP message parts. The base class for receiving SOAP messages is the SOAPReceiver class. You must inherit from this class to implement your own receiver:
The next step is to override the receive method and process the SOAP messages to perform the required operations. The following example shows how to process a SOAP message to concatenate two strings.

In the application hosting the Web Service you need to register the SOAPReceiver to start receiving SOAP messages:

In case the Web Service uses the HTTP protocol, it must be registered as part of the Web.Config file in the ASP.NET application. The following code adds a handler to all messages targeted at.

To send messages to the Web Services use the SoapSender class. This class provides the ability to transmit a SoapEnvelope via TCP or HTTP protocol to a specified destination. But first create a SOAPMessage using the SOAPEnvelope class. The following message is an example of the concatenation of two strings.

The following code shows how to create these messages by using the SoapEnvelope class.
SoapEnvelope CreateConcatMessage()
{
SoapEnvelope env = new SoapEnvelope();
env.CreateBody();
env.Body.InnerXml = "<v:Concat xmlns:v='urn:StrManager'>
<FirstStr>Hello</FirstStr>
<SecondStr>World</SecondStr>
</v:Concat>";
return env;
}
To send a SOAP message with the SoapSender class, first instantiate a SoapSender object and assign the destination URI to it. Next, to identify an operation, specify the message action through the SoapEnvelope.Context.Action property. Finally, call the Send method and pass in the SoapEnvelope object you want to send:








garystewart247Posted Aug 20, 2007, 12:20 PM
The code examples are not posted. Can you provide? Thank you! Gary