Structure of a WSDL message

The WSDL schema defines operations and their associated XML elements, which define the payloads of the operations' messages.

Each operation can have input (request) and output (response) messages. When HCL OneTest API processes the WSDL file, it creates a schema constrained structure for each of these messages. The basic structure for these messages is similar for all of the WSDL messages. Explanations use examples from the UK Lottery service that is provided by 4duk.net and the XMethods Demo Currency Converter WSDL.

The root message and SOAP Envelope

The root level message represents the SOAP Envelope and is defined by the operation that is being invoked. The name of the root message consists of the following three parts:
  • The name of the operation
  • The direction of the SOAP message (input or output)
  • The name of the actual WSDL message that is being created
This name is in the format Operation_Name__Direction__SOAP Message Name. For example, a WSDL defines an operation that is called LOTTO_Num_Single_Hist that has an output SOAP message called LOTTO_Num_Single_HistResponse. When this message is selected, the root message has the following name:

LOTTO_Num_Single_Hist__OUTPUT__LOTTO_Num_Single_HistResponse

The child elements of the root message fall into two categories: any number of namespace fields and the SOAP body element.

SOAP Envelope namespace attributes

The WSDL definition can define any number of namespace attributes that are assigned to its SOAP Envelopes. These namespaces fall into two categories; the standard SOAP namespaces that appear on all SOAP Envelopes, and instance-specific namespaces. When you select a SOAP Envelope root message, only the instance-specific namespace attributes are created. The standard namespaces are assumed and added to the XML payload by the formatters during message compilation or removed during message de-compilation.

Overview of the SOAP body element

The SOAP Envelope root message can have only one child message. This message represents the contents of the SOAP body element and is defined by the WSDL file's message definition that corresponds to the selected SOAP Envelope. The exact structure of the root message within HCL OneTest API depends on whether the SOAP Envelope defines a Document Literal or an RPC Encoded message.

Document literal body elements

The following is an extract from a WSDL schema definition that is taken from the 4duk lottery service WSDL. The following extract contains the operation definition and the input message definition for an operation that is called LOTTO_NumCheck_SingleSet_HistRequest and is defined as part of a Document Literal WSDL definition.


<definitions xmlns:ns0=http://www.4d.com/namespace/default>
   <operation name="LOTTO_NumCheck_SingleSet_Hist">
      <input message="tns:LOTTO_NumCheck_SingleSet_HistRequest"/>
      <output message="tns:LOTTO_NumCheck_SingleSet_HistResponse"/>
   </operation>
   <message name="LOTTO_NumCheck_SingleSet_HistRequest">
      <part name="FourD_ArgIn" 
               element="tns:LOTTO_NumCheck_SingleSet_Hist"/>
   </message>
</defintions>

As this WSDL defines Document Literal style SOAP Envelopes, then HCL OneTest API creates corresponding Document Literal style SOAP Body messages.

Document Literal WSDL message elements have only one child part element. This part element describes the children of the SOAP Body Element. The part element generally contains an element attribute. This attribute is a reference to an XML element defined within the WSDLs XML schema definition. In the previous example, the part refers to the tns:LOTTO_NumCheck_SingleSet_Hist element. This reference indicates the schema defined XML element that the SOAP Body's message structure is created from. Within HCL OneTest API, the creation of the SOAP Body's child structure continues in a manner that is identical to that of normal XML schema-constrained message population that is found elsewhere within the tool (for example, when you are using the XML Message Text Formatter).

The name of the SOAP Body message is set as the name of the element referred to by the element attribute and includes any required namespace prefixes. In the example, it is LOTTO_NumCheck_SingleSet_Hist.

The LOTTO_NumCheck_SingleSet_Hist element is defined within the XML schema as having six child elements with a text child of type integer and one element with a Boolean field.

RPC encoded body elements

The following is an extract that is taken from the XMethods Demo Currency Converter WSDL. This extract contains the operation definition and the input message for an operation that is called getRate and is defined as part of an RPC Encoded WSDL definition.


<definitions 
   xmlns:tns=http://www.xmethods.net/sd/CurrencyExchangeService.wsdl>
      <operation name="getRate">
         <input message="tns:getRateRequest"/>
         <output message="tns:getRateResponse"/>
      </operation>
      <message name="getRateRequest">
         <part name="country1" type="xsd:string"/>
         <part name="country2" type="xsd:string"/>
      </message>
</defintions>

An RPC Encoded WSDL message definition can have any number of parts. These parts define the child elements of the SOAP Body element. Each part has a name and a type attribute. The type attribute can either contain a simple XML schema type (integer, string, decimal, and so on) or a reference to the WSDLs XML schema definition.

If the type references a scalar type, the resultant HCL OneTest API message is created as an XML element message with a child element of the specified type. The name of the message is provided by the part's name attribute.

If the type references the XML Schema definition, the resultant HCL OneTest API message is created according to the referenced XML schema object. The name is the same as the name of that XML schema object.

If the whole message represents an input (request) message, the name of the SOAP Body Element is set as operation name.

If the message represents an output (response) message, the name of the SOAP Body Element is set as the operation name response.

The names are then qualified by using any applicable namespace prefixes. For example, for the Demo Currency Converter, the name of the request message's SOAP Body Element is set as tns:getRate and the response is named tns:getRateResponse.