Sunday, November 16, 2008

How to contribute to WSF/PHP project

As an open source software development project, WSF/PHP always encourage users,developers to raise bugs, and post patches etc. Of course if you have any great idea related to WSF/PHP or some enhancement to WSF/PHP, you are most welcome to contribute.

Lets see how you can contribute to WSF/PHP project in various ways. If you encounter a bug, you can first check on the svn to see whether it is already fixed as well.

1. How do I provide a patch to WSF/PHP .

Step1.

WSF/PHP uses svn as its version control system. You can checkout the source code of WSF/PHP from the following URL.

https://wso2.org/repos/wso2/trunk/wsf/php/

On windows you can use Tortoise SVN to checkout the source code as follows.

Step 1.

Create a folder to which you will checkout the source code.

Step2. Check out the code

img1

img2 

Now you can make any changes or additions, you would like to make.

Step 3.

Use create patch option in Tortoise svn to create a patch.

image 

This should provide you with a patch file.

Step 4.

Go to WSO2 Jira project and select WSF/PHP project

jira1

Select WSF/PHP project    

 jira2                                         

Go to create new issue options and select WSO2 WSF/PHP from projects drop down menu. Then select the issue type

jira3

Now in this issue form, you can fill out information about the issue.

jira4

Next fill out the issue description, your testing environment, and attach the patch.

jira5

Now click create button to create the issue.

This way you can contribute to WSF/PHP project which is used by a large number of PHP Developers worldwide. Looking forward to your contributions.

Monday, November 10, 2008

Introduction to reliable messaging part 3

In this blog post, we will look at how you can send multiple application messages within a single sequence reliably using

WSClient API.  For this purpose WSClient has an option named willContinueSequence. If you intend to send only a since application message within your reliable sequence, then you do not need to touch this option. However, when sending multiple application messages, you need to use it as follows.

1. When sending the first message, set willContinueSequence=TRUE in WSClient.

2. Send your application messages by using WSMessage object.

3. When you want to send the final application message to be sent within the reliable sequence, set the option lastMessage to true.

Here is a code example demonstrating this.

Step 1. First create an application message.

$requestPayloadString = <<<XML
    <ns1:pingString xmlns:ns1="http://wso2.org/wsfphp/samples/reliable">
        <text>Hello World!</text>
    </ns1:pingString>
XML;

Step 2. Create a WSClient object with willContinueSequence option set to TRUE

$client = new WSClient(array( "reliable" => TRUE, "useWSA" => TRUE, "willContinueSequence" => TRUE));

Step 3. Create and Send WSMessage objects containing application messages.

$message = new WSMessage($requestPayloadString,
           array( "to" => "http://localhost/samples/reliable/ping_service_rm.php",
                  "action" => http://wso2.org/wsfphp/samples/pingString));

$client->send($message);

$message1 = new WSMessage($requestPayloadString,
            array( "to" => "http://localhost/samples/reliable/ping_service_rm.php",
                   "action" => "http://wso2.org/wsfphp/samples/pingString"));

    $client->send($message1);

Step 4. When you want to send the last application message, set the option lastMessage to true in WSMessage object.

$message2 = new WSMessage($requestPayloadString,
    array( "to" => "http://localhost/samples/reliable/ping_service_rm.php",
           "action" => "http://wso2.org/wsfphp/samples/pingString",
           "lastMessage" => TRUE));

$client->send($message2);

Note that this is a ping service and hence the use of the method send in WSClient. You can similarly use request method as well.

Monday, November 3, 2008

Introduction to reliable messaging part 2

In my previous blog post, we had a look at a set of messages exchanged between a web services client and a server using WS-Reliable Messaging protocol.  Today, we will explore the API available in WSF/PHP to achieve reliable messaging.

WS-Reliable messaging API in WSF/PHP is a simple an uncomplicated one. Lets go thorough each of the options available on WS-Client to achieve reliable messaging.

To enable WS-Reliable Messaging you need to use the "reliable" option in WS-Client. However, for WS-RM to work, it is mandatory to have WS-Addressing enabled. There for you need to  enable WS-Addressing or at least define the "action" option in WS-Client. If the action is present, and "reliable" options is set to "true", WSF/PHP will automatically enables WS-Addressing and enables Reliable Messaging. So following options are valid on WS-Client to enable reliable messaging.

1.

oparray["action"] = "http://wso2.org/wso2-wsf-php";

oparray["reliable"]= TRUE;

client = new WSClient(oparray);

2.

oparray["action"] ="http://wso2.org/wso2-wsf-php"

oparray["reliable"]=1.1

In this option, we are telling WS-Client to use WS-RM version 1.1.

In my next blog post, we will explore other configuration options of WSClient and WS-Service

Monday, October 27, 2008

Introduction to Reliable Messaging with WSF/PHP

 

With WSF/PHP you can add reliability to your web services integrations . Due to the  nature of PHP, WSF/PHP supports only single channel reliable messaging. Single channel means you are using the same channel to transmit both the request and response.

When reliable messaging is used, in addition to the actual message being transmitted , there will be handshake interactions between the client and the service to make sure that the sent message is actually delivered to the service. In addition the , reliable messaging middleware make sure that if the receiver endpoint down, it will keep polling till the message is delivered etc.

Let see how you can implement a simple reliable messaging client using WSF/PHP.

These are the requirements.

1. You service endpoint should be able to handle single channel reliable messaging.

2.Then you need to enable addressing.

In RM, the communication happens using a sequence. The initial handshake is to build this sequence, and with a sequence , one or more application messages is transmitted. Once the messaging transmission is complete, the sequence is terminated.

So the messages exchanged in a single channel scenario is as follows. I am using the actual xml messages exchanged in the echo_client_rm.php sample that comes with WSF/PHP release here.

1. Client sending the CreateSequence Message to the service.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:To>http://localhost/samples/reliable/echo_service_rm.php</wsa:To>
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</wsa:Action>
      <wsa:ReplyTo>
         <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
      </wsa:ReplyTo>
      <wsa:MessageID>urn:uuid:6dbfe9a0-304f-415e-91d1-49d2993bcf56</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body>
      <wsrm:CreateSequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
         <wsrm:AcksTo xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
            <wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
         </wsrm:AcksTo>
         <wsrm:Offer xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
            <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
         </wsrm:Offer>
      </wsrm:CreateSequence>
   </soapenv:Body></soapenv:Envelope>

2. Service responding with a CreateSequenceResponse message.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:To>http://www.w3.org/2005/08/addressing/anonymous</wsa:To>
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</wsa:Action>
      <wsa:From>
         <wsa:Address>http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
      </wsa:From>
      <wsa:MessageID>urn:uuid:48020317-4e90-4b79-97ae-2fa9b78c544b</wsa:MessageID>
      <wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply" xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:6dbfe9a0-304f-415e-91d1-49d2993bcf56</wsa:RelatesTo>
   </soapenv:Header>
   <soapenv:Body>
      <wsrm:CreateSequenceResponse xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
         <wsrm:Identifier>8883a8b9-9f6a-4e40-b78a-872a2708a4b3</wsrm:Identifier>
         <wsrm:Accept xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
            <wsrm:AcksTo xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
               <wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
            </wsrm:AcksTo>
         </wsrm:Accept>
      </wsrm:CreateSequenceResponse>
   </soapenv:Body></soapenv:Envelope>

3. Client sending the sequence Message

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsrm:Sequence soapenv:mustUnderstand="1" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>8883a8b9-9f6a-4e40-b78a-872a2708a4b3</wsrm:Identifier>
         <wsrm:MessageNumber xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">1</wsrm:MessageNumber>
         <wsrm:LastMessage xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"/>
      </wsrm:Sequence>
      <wsa:To>http://localhost/samples/reliable/echo_service_rm.php</wsa:To>
      <wsa:Action>http://wso2.org/wsfphp/samples/echoString</wsa:Action>
      <wsa:MessageID>urn:uuid:8e275ba1-b34b-49c1-92fa-ce86782ff803</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body>
      <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples">       
         <text>Hello World!</text>   
      </ns1:echoString>
   </soapenv:Body></soapenv:Envelope>

4. Service Responding with a SequenceAcknowledgement message. Since this is an echo service, in addition to sending the acknowledgement, the service also initiate a sequence here and send the application message back to the client.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsrm:Sequence soapenv:mustUnderstand="1" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
         <wsrm:MessageNumber xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">1</wsrm:MessageNumber>
         <wsrm:LastMessage xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"/>
      </wsrm:Sequence>
      <wsrm:SequenceAcknowledgement soapenv:mustUnderstand="0" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>8883a8b9-9f6a-4e40-b78a-872a2708a4b3</wsrm:Identifier>
         <wsrm:AcknowledgementRange Lower="1" Upper="1"/>
      </wsrm:SequenceAcknowledgement>
      <wsa:Action>http://wso2.org/wsfphp/samples/echoString</wsa:Action>
      <wsa:ReplyTo>
         <wsa:Address>http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
      </wsa:ReplyTo>
      <wsa:From>
         <wsa:Address>http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
      </wsa:From>
      <wsa:MessageID>urn:uuid:307e881d-8ac7-4cb4-8acf-0eb04831707f</wsa:MessageID>
      <wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply" xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:8e275ba1-b34b-49c1-92fa-ce86782ff803</wsa:RelatesTo>
   </soapenv:Header>
   <soapenv:Body>
      <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples">       
         <text>Hello World!</text>   
      </ns1:echoString>
   </soapenv:Body></soapenv:Envelope>

5. Client send the SequenceAcknowledgement message to the service.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsrm:SequenceAcknowledgement soapenv:mustUnderstand="0" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
         <wsrm:AcknowledgementRange Lower="1" Upper="1"/>
      </wsrm:SequenceAcknowledgement>
      <wsa:To>http://localhost/samples/reliable/echo_service_rm.php</wsa:To>
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement</wsa:Action>
      <wsa:MessageID>urn:uuid:3b2b7a50-f962-4027-b240-5eea57142df1</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body/></soapenv:Envelope>

 

6. Now the service sends back a TerminateSequence Message.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</wsa:Action>
      <wsa:MessageID>urn:uuid:6e8178c6-a566-4010-a77e-d05af67ad21a</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body>
      <wsrm:TerminateSequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
         <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
      </wsrm:TerminateSequence>
   </soapenv:Body></soapenv:Envelope>

Similarly the client and service exchanges TermianteSequenceResponse messages as well.

I am sure, now you have some understanding on what actually happens when you try to send a soap message reliably from  one endpoint to another. In my next blog post, we will discuss how to configure WSF/PHP to implement reliable clients and services.

Introduction to Reliable Messaging with WSF/PHP

 

With WSF/PHP you can add reliability to your web services integrations . Due to the  nature of php, WSF/PHP supports only single channel reliable messaging. Single channel means you are using the same channel to transmit both the request and response.

So what is the nature of a reliable messing interaction ?

When reliable messaging is used, in addition to the actually message being transmitted , there will be handshake interactions between the client and the service to make sure that the send message is actually delivered to the service. In addition the , reliable messaging middleware handles make sure that if the receiver endpoint down, it will keep polling till the message is delivered etc.

Let see how you can implement a simple reliable messaging client using WSF/PHP.

These are the requirements.

1. You service endpoint should be able to handle single channel reliable messaging.

2.Then you need to enable addressing.

In RM, the communication happens using a sequence. The initial handshake is to build this sequence, and with a sequence , one or more application messages is transmitted. Once the messaging transmission is complete, the sequence is terminated.

So the messages exchanged in a single channel scenario is as follows. I am using the actually xml messages exchanged in the echo_client_rm.php sample that comes with WSF/PHP release here.

1. Client sending the CreateSequence Message to the service.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:To>http://localhost/samples/reliable/echo_service_rm.php</wsa:To>
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</wsa:Action>
      <wsa:ReplyTo>
         <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
      </wsa:ReplyTo>
      <wsa:MessageID>urn:uuid:6dbfe9a0-304f-415e-91d1-49d2993bcf56</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body>
      <wsrm:CreateSequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
         <wsrm:AcksTo xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
            <wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
         </wsrm:AcksTo>
         <wsrm:Offer xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
            <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
         </wsrm:Offer>
      </wsrm:CreateSequence>
   </soapenv:Body></soapenv:Envelope>

2. Service responding with a CreateSequenceResponse message.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:To>http://www.w3.org/2005/08/addressing/anonymous</wsa:To>
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</wsa:Action>
      <wsa:From>
         <wsa:Address>http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
      </wsa:From>
      <wsa:MessageID>urn:uuid:48020317-4e90-4b79-97ae-2fa9b78c544b</wsa:MessageID>
      <wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply" xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:6dbfe9a0-304f-415e-91d1-49d2993bcf56</wsa:RelatesTo>
   </soapenv:Header>
   <soapenv:Body>
      <wsrm:CreateSequenceResponse xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
         <wsrm:Identifier>8883a8b9-9f6a-4e40-b78a-872a2708a4b3</wsrm:Identifier>
         <wsrm:Accept xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
            <wsrm:AcksTo xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
               <wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
            </wsrm:AcksTo>
         </wsrm:Accept>
      </wsrm:CreateSequenceResponse>
   </soapenv:Body></soapenv:Envelope>

3. Client sending the sequence Message

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsrm:Sequence soapenv:mustUnderstand="1" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>8883a8b9-9f6a-4e40-b78a-872a2708a4b3</wsrm:Identifier>
         <wsrm:MessageNumber xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">1</wsrm:MessageNumber>
         <wsrm:LastMessage xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"/>
      </wsrm:Sequence>
      <wsa:To>http://localhost/samples/reliable/echo_service_rm.php</wsa:To>
      <wsa:Action>http://wso2.org/wsfphp/samples/echoString</wsa:Action>
      <wsa:MessageID>urn:uuid:8e275ba1-b34b-49c1-92fa-ce86782ff803</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body>
      <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples">       
         <text>Hello World!</text>   
      </ns1:echoString>
   </soapenv:Body></soapenv:Envelope>

4. Service Responding with a SequenceAcknowledgement message. Since this is an echo service, in addition to sending the acknowledgement, the service also initiate a sequence here and send the application message back to the client.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsrm:Sequence soapenv:mustUnderstand="1" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
         <wsrm:MessageNumber xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">1</wsrm:MessageNumber>
         <wsrm:LastMessage xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"/>
      </wsrm:Sequence>
      <wsrm:SequenceAcknowledgement soapenv:mustUnderstand="0" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>8883a8b9-9f6a-4e40-b78a-872a2708a4b3</wsrm:Identifier>
         <wsrm:AcknowledgementRange Lower="1" Upper="1"/>
      </wsrm:SequenceAcknowledgement>
      <wsa:Action>http://wso2.org/wsfphp/samples/echoString</wsa:Action>
      <wsa:ReplyTo>
         <wsa:Address>http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
      </wsa:ReplyTo>
      <wsa:From>
         <wsa:Address>http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>
      </wsa:From>
      <wsa:MessageID>urn:uuid:307e881d-8ac7-4cb4-8acf-0eb04831707f</wsa:MessageID>
      <wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply" xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:8e275ba1-b34b-49c1-92fa-ce86782ff803</wsa:RelatesTo>
   </soapenv:Header>
   <soapenv:Body>
      <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples">       
         <text>Hello World!</text>   
      </ns1:echoString>
   </soapenv:Body></soapenv:Envelope>

5. Client send the SequenceAcknowledgement message to the service.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsrm:SequenceAcknowledgement soapenv:mustUnderstand="0" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
         <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
         <wsrm:AcknowledgementRange Lower="1" Upper="1"/>
      </wsrm:SequenceAcknowledgement>
      <wsa:To>http://localhost/samples/reliable/echo_service_rm.php</wsa:To>
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement</wsa:Action>
      <wsa:MessageID>urn:uuid:3b2b7a50-f962-4027-b240-5eea57142df1</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body/></soapenv:Envelope>

 

6. Now the service sends back a TerminateSequence Message.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</wsa:Action>
      <wsa:MessageID>urn:uuid:6e8178c6-a566-4010-a77e-d05af67ad21a</wsa:MessageID>
   </soapenv:Header>
   <soapenv:Body>
      <wsrm:TerminateSequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
         <wsrm:Identifier>df2ceab0-b04f-428a-bb94-0cfdcb0a524b</wsrm:Identifier>
      </wsrm:TerminateSequence>
   </soapenv:Body></soapenv:Envelope>

Similarly the client and service exchanges TermianteSequenceResponse messages as well.

I am sure, now you have some understanding on what acctually happens when you try to send a soap message reliably from  one endpoint to another. In my next blog post, we will discuss how to configure WSF/PHP to implement reliable clients and services.

Thursday, October 23, 2008

How to learn the SOAP version by looking at a soap message

I have seen number of questions on the forums on issues related to this. So here are some tips on getting to know spec versions by looking at a soap message with http headers.

Here is an example SOAP1.1 one message.

POST /samples/echo_service.php HTTP/1.1
User-Agent: Axis2C/1.5.0
SOAPAction: ""
Content-Length: 242
Content-Type: text/xml;charset=UTF-8
Host: 127.0.0.1:8080

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples">
         <text>Hello World!</text>
      </ns1:echoString>
   </soapenv:Body></soapenv:Envelope>

 

I have marked highlighted the important points.

In SOAP1.1

1.  Content-Type will be "text/xml".

2. SOAPAction is a separate HTTP Header

3. SOAP envelope namespace uri is  "http://schemas.xmlsoap.org/soap/envelope/"

Here is a SOAP 1.2 message.

POST /samples/echo_service.php HTTP/1.1
User-Agent: Axis2C/1.5.0
Content-Length: 240
Content-Type: application/soap+xml;charset=UTF-8;action="urn:echoString"
Host: 127.0.0.1:8080

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header/>
   <soapenv:Body>
      <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples">
         <text>Hello World!</text>
      </ns1:echoString>
   </soapenv:Body></soapenv:Envelope>

In SOAP 1.2

1. Content-Type header is "application/soap+xml"

2. SOAP envelope namespace uri is "http://www.w3.org/2003/05/soap-envelope".

3. soap action header will go in the Content-type header as 'action'

Depending on you requirement, you can switch between between soap versions by passing the option "useSOAP"=>1.1 or "useSOAP"=>1.2.

For a service in WSF/PHP, the soap version does not matter since the framework is capable of handling either type.

Wednesday, October 22, 2008

How to Get WS-Security working without WS-Addressing in WSF/PHP

Usually, most security scenarios use WS-Addressing. But there are scenarios that uses security without WS-Addressing. Due to configuration  file settings, WSF/PHP works with WS-Security only when WS-Addressing is also used. However, by doing some simple changes to a couple of Xml files, you can get WSF/PHP to support some security scenario's that does not use WS-Addressing.

Here is what you need to do.

1. Step One.

Open the axis2.xml file found in was_c directory. In it,  change in inflow by adding another phase named Security as follows.

<phaseOrder type="inflow"> - <!-- System pre defined phases       -->

<phase name="Transport" />

<phase name="PreDispatch" />

<phase name="Dispatch" />

<phase name="PostDispatch" />

<!-- End system pre defined phases       -->

<!-- After PostDispatch phase, module or service author can add any phase as required  -->

<!-- User defined phases could be added here -->

<phase name="Security" />

<phase name="Rahas" />

<phase name="RMPhase" />

</phaseOrder>

I have highlighted the line added in red.

2. Step two

Open the module.xml file found in wsf_c/modules/rampart/ directory and change the inflow elements phase name attribute from "PreDispatch" to "Security" as follows.

<inflow>
       <handler name="RampartInHandler" class="mod_rampart">
           <order phase="Security"/>
       </handler>
   </inflow>

Again, I have highlighted the change.

That's all you need to do to get WS-Security to work without using WS-Addressing.

Note that,for this to work, you will have to have either SOAPAction or an element that matches the operation name in Soap Body. Of course there are some WS-Security scenarios that cannot work without WS-Addressing.