Home > Articles > Web Services

  • Print
  • + Share This
This chapter is from the book

Messages

Messages define the way information is actually transmitted during communication between the service and its clients. In the case of SOAP clients, the message would help to define the SOAP messages that are being sent. In the case of clients using HTTP protocols, the message would define Form or URI string messages.

The message element itself contains a name attribute that is used to uniquely identify the message. When Visual Studio/ .NET creates a WSDL document for you, it typically creates a message whose name is built by combining the method's name, the Port type, and the direction of travel, relative to the service, of the message. For example, myMethodPostIn, would be the name of a message calling a method named myMethod using the Post port.

A message also contains zero or more part elements. part elements define the actual parts of the message being sent. These part elements represent parameters and results being sent back and forth between the client and the service. A part consists of two attributes, name and element. The name attribute is either the name of an argument of the method, or as in the case of SOAP port messages, simply the "parameters". The element attribute is used to determine the type of the argument or response part.

The following is a message for a SOAP port call to a method named StringReturnSoapIn. Note that since the message describes a SOAP communication, the name is parameters and the type is a complex type called StringReturn.

<message name="StringReturnSoapIn">
  <part name="parameters" element="s0:StringReturn" />
</message>

The return message for this method looks very similar, with the substitution of Out for In in the message's name.

<message name="StringReturnSoapOut">
  <part name="parameters" element="s0:StringReturnResponse" />
</message>

When one of the HTTP protocols is being used, the part elements actually contain the parameter's name and type, as seen below. This message would describe calling a method, ParamLongReturn, via HttpPost and passing in two strings named iNum1 and iNum2.

<message name="ParamLongReturnHttpPostIn">
  <part name="iNum1" type="s:string" />
  <part name="iNum2" type="s:string" />
</message>

The return of the method would make use of the message below to return a long. The return, or Out, messages of HTTP protocol messages are always named Body.

<message name="ParamLongReturnHttpPostOut">
  <part name="Body" element="s0:long" />
</message>
  • + Share This
  • 🔖 Save To Your Account