This post is part of Issue 5’s answer

 

As a result of step 1 (How to define a <MessagePredicate>) we go the following template for our <MessagePredicate>

 

      <wsp:MessagePredicate wsp:Usage="wsp:Required">

            wsp:GetBody(.)/here/goes/my/path > 4

      </wsp:MessagePredicate>

 

Given our CLR message type:

 

[XmlType(Namespace="uri:isssue5/types")]

public class Issue5ReqMsg

{

            public int something;

}

 

It’s tempting to define the following XPath expression:

 

<wsp:MessagePredicate wsp:Usage="wsp:Required">

            wsp:GetBody(.)/Issue5ReqMsg/something > 4

</wsp:MessagePredicate>

 

 

Ok, we’ve forgotten to define the element’s namespaces. By doing so, the expression looks the following:

 

<wsp:MessagePredicate wsp:Usage="wsp:Required" xmlns:it=”uri:isssue5/types“ >

            wsp:GetBody(.)/it:Issue5ReqMsg/it:something > 4

</wsp:MessagePredicate>

 

But does this really work?

 

Let’s have a look at the message that will be sent across the wire:

 

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                     xmlns:xsd="http://www.w3.org/2001/XMLSchema"

                     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

         <soap:Body>

            <reqMsg xmlns="uri:isssue5/wsdl">

               <something xmlns="uri:isssue5/types">6</something>

            </reqMsg>

         </soap:Body>

</soap:Envelope>

 

Ooops, surprise, surprise, there is no element called <Issue5ReqMsg> instead there is an element called <reqMsg>, but why?

A quick look at the wsdl file answers the question:

 

<types xmlns:s="http://www.w3.org/2001/XMLSchema"

         xmlns:s0="uri:isssue5/wsdl"

         xmlns:s1="uri:isssue5/types"

         targetNamespace="uri:isssue5/wsdl">

                             

         <s:schema elementFormDefault="qualified" targetNamespace="uri:isssue5/wsdl">

            <s:import namespace="uri:isssue5/types" />

            <s:element name="reqMsg" type="s1:Issue5ReqMsg" />

            <s:element name="DoSomethingResult" type="s1:Issue5RespMsg" />

         </s:schema>

         <s:schema elementFormDefault="qualified" targetNamespace="uri:isssue5/types">

            <s:complexType name="Issue5ReqMsg">

              <s:sequence>

                 <s:element minOccurs="1" maxOccurs="1" name="something" type="s:int" />

              </s:sequence>

            </s:complexType>

            <s:complexType name="Issue5RespMsg">

               <s:sequence>

                 <s:element minOccurs="1" maxOccurs="1" name="something" type="s:int" />

               </s:sequence>

            </s:complexType>

         </s:schema>

      </types>

      <message name="DoSomethingSoapIn">

         <part name="reqMsg" element="s0:reqMsg" />

      </message>

      <message name="DoSomethingSoapOut">

         <part name="DoSomethingResult" element="s0:DoSomethingResult" />

      </message>

 

 

Our document literal Web Service requires an element within its message part. Therefore, the two elements reqMsg and DoSomethingResult have been created. Note that these two elements contain to another namespace than the two corresponding types. The next post will discuss how the creation of these elements can be controlled using .NET attributes.

 

Coming back to our quiz, the XPath expression has to look the following:

 

<wsp:MessagePredicate wsp:Usage="wsp:Required"

         xmlns:it="uri:isssue5/types"

         xmlns:iw="uri:isssue5/wsdl">

 

         wsp:GetBody(.)/iw:reqMsg/it:something > 4

</wsp:MessagePredicate>