- WS-Addressing Action is used by web services to dispatch the operation for an incoming request SOAP message. It is one way of dispatching operations in WSF/PHP and it base Apach Axis2/C, other ways are SOAP action based dispatching which covers in my early blog “The Use of SOAP Action with WSF/PHP“, Body based dispatching and URI based dispatching.
- In WSF/PHP client, we can enable the addressing by setting the “action” field in the request WSMessage instance and setting “useWSA”=> TRUE in the WSClient instance. Here is an example.
$requestPayloadString = <<<XML <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples"> <text>Hello World!</text> </ns1:echoString> XML; $client = new WSClient(array("to" => "http://localhost/samples/echo_service.php", "useWSA" => TRUE)); $requestMessage = new WSMessage($requestPayloadString, array("action" => "http://localhost/samples/echo_service/echoString")); $responseMessage = $client->request($requestMessage); printf("Response = %s <br>", htmlspecialchars($responseMessage->str));
If you doesn’t set “useWSA” => TRUE explicitly, the client will send the action as a SOAP action rather than a WSA Action. The above is the same example I used in demonstrating SOAP action with just the addition of “useWSA” option.
- You can select WS-Addressing version among “submission” which .NET support by default and “1.0”, just by mention it in the “useWSA” field.
I.e.“useWSA” => “submission” Then the namespaces are having the values defined in the submission specification of WS-Addressing. “useWSA” => 1.0 Then the namespace are having the values defined in the WS-Addressing 1.0 spec. - In the option “actions” in the WSService, we can provide the action to operation map, so the service will direct the SOAP messages to the correct operation by looking at the WS-Addressing action of the SOAP message.
Here is a sample code that use action to dispatch the operation.function echoStringFunc($inMessage) { // logic of echoString operation } function echoIntFunc($inMessage) { // logic of echoInt operation } // we will take echoString and echoInt as tow operations $operations = array("echoString" => "echoStringFunction", "echoInt" => "echoIntFunction"); // soap action to operation map $actions = array("http://localhost/samples/echo_service/echoString" => "echoString", "http://localhost/samples/echo_service/echoInt" => "echoInt"); // creating the service with the operations and actions set $service = new WSService(array("operations" => $operations, "actions" => $actions)); $service->reply();
Note that this code is same as the code I post in a previous blog “The Use of SOAP Action with WSF/PHP” which uses SOAP action to dispatch the operation. In fact WSService will adjust to dispatch SOAP messages, so if there is a SOAP action in the message, it will be dispatched using that, and if it contains WS-Addressing action, it will used to do dispatching without the need of writing a single additional line of code. Note that this same code for both “submission” and “1.0” WS-Addressing versions.
- In a WSDL 1.1, WS-Addressing action can be declared in the message element in the portType section.
<wsdl:portType name="echoPortType"> <wsdl:operation name="echoString"> <wsdl:input message="ns0:echoStringRequest" wsaw:Action="http://localhost/samples/echo_service/echoString"/> <wsdl:output message="ns0:echoStringResponse" wsaw:Action="http://localhost/samples/echo_service/echoStringResponse"/> </wsdl:operation> <wsdl:operation name="echoInt"> <wsdl:input message="ns0:echoIntRequest" wsaw:Action="http://localhost/samples/echo_service/echoInt"/> <wsdl:output message="ns0:echoIntResponse" wsaw:Action="http://localhost/samples/echo_service/echoIntResponse"/> </wsdl:operation> </wsdl:portType>
When you use WSF/PHP in wsdl mode, it will pick the action declared in the WSDL and set it in the SOAP message, if you have enabled the addressing for the WSClient by setting non-null value for “useWSA” option.
Tags
2 minutes adb axis2/c base64 binary bps carbon codegen DataService data services enterprise esb Governance guide install mashup mtom php policy registry release REST RESTful security services SOA SOAP Tools tutorial Web Service web services wordpress WS-* ws-security wsas WSClient WSDL wsdl2php wsdl generation wsdl mode wsf wsf/php wso2 xml xml schemaArchives
- July 2010 (1)
- June 2010 (1)
- May 2010 (3)
- February 2010 (1)
- January 2010 (6)
- December 2009 (1)
- November 2009 (1)
- October 2009 (2)
- August 2009 (1)
- July 2009 (3)
- June 2009 (2)
- April 2009 (1)
- March 2009 (3)
- February 2009 (4)
- January 2009 (5)
- December 2008 (12)
- November 2008 (20)
- October 2008 (21)
- September 2008 (21)
- August 2008 (9)
- July 2008 (7)
Calendar
Meta
Pages
-
Recent Posts