I’ve found the following thoughts quite interesting…

 

Prolog:

The WS-Policy framework allows you to make statements about your Web Services such as their preferences, requirements or capabilities. Since policies are part of the messaging infrastructure, they can be applied to services after they’ve been deployed.

WS-PolicyAssertions specifies some predefined assertions. Part of this specification is the MessagePredicate assertion: It can be used to make statements about a message.

 

But now the quiz:

The following example consists of a policy assertion and a Web Service implementation. The idea is to define an assertion that only accepts messages where Issue5ReqMsg.something is greater than 4. How would your policy assertion look like?

As always, answer and explanation will follow…

 

 

<wsp:MessagePredicate wsp:Usage='wsp:Required'

      <!-- Assertion goes here -->

</wsp:MessagePredicate>

 

 

namespace Issue5

{

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

      public class Issue5ReqMsg

      {

            public int something;

      }

     

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

      public class Issue5RespMsg

      {

            public int something;

      }

 

      [WebService(Namespace="uri:isssue5/wsdl")]

      public class Issue5

      {

            [WebMethod]

            [SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)]

            public Issue5RespMsg DoSomething(Issue5ReqMsg reqMsg)

            {

                  Issue5RespMsg respMsg = new Issue5RespMsg();

                  respMsg.something = reqMsg.something * 5;

                  return respMsg;

            }

      }

}