PHP Web Services - Authentication Based on Client’s IP

Saturday, December 27, 2008

This blog post PHP Web Services - Authentication Based on Client’s IP explains with code samples how a PHP web service can be written to authenticate clients based on their IPs.


Saturday, December 20, 2008

Both REST ( Representational states transfer) and SOAP is widely adopted techniques for building distributed systems. REST is an architectural style for implementing systems on top of HTTP infrastructure.  A large number of Specifications has been developed on top of SOAP and there are large number of SOAP stacks both open source and proprietary out there implementing large part of this WS* stack.

Both these d techniques have their advantages and drawbacks. Here are few of the advantages and disadvantages of each paradigm.



1. Based on few simple principles which are already in wide adoption on the Web itself

2. Can be implemented very quickly.

3. Ideal for providing simple API's to the users. (Eq Whether Services, Flicker, Yahoo REST services )

4. Amount of learning required to get started is minimum in comparison to SOAP

5. Has a very large following amount the scripting community


1. If the system is a very large one, then designing based on REST could become a very complex task.

2. Implementing Security on a REST system is one major issues. Although HTTPS, and HTTP Authentication can be used,  they only provide transport level security.



1. Well designed mature technology

2. Has been widely adopted in industry

3. Large number of SOAP stacks available to choose from.

4. Has support for Both Transport level and message level security which is a big advantage over REST.

5. Supports multiple protocol bindings ( Not just HTTP)

6. Ideal for implementing complex enterprise  systems since the SOAP Stacks cater for security, reliability, transactions ect.


1. Complex in comparison to REST

2. Big learning curve required

3. Difficult to debug a complex system

One great thing about using WSF/PHP is that it can support Both of these techniques simultaneously. However, if you are building a complex system which require  security, I would always recommend the use of SOAP.

Data Services Best Practices

Thursday, December 18, 2008

Is that data services are for converting database tables to web service operations?. Is that the right way to adapt SOA?. This post titled 'Data Services Best Practices' explains how you should develop data services without violating SOA principles

Sending Encrypted Binary Messages With PHP Web Services

Sunday, December 14, 2008

Web services has made the communication between heterogeneous environments (say PHP with .NET or Java) a reality. It has defines standards for communicate not only with texts but also with binaries. And more importantly you can keep these communication confidential using encrypted messages according to your requirement. In the post "Sending Encrypted Binary Messages With PHP Web Services" , we will look at how we can implement such a system with PHP in one side.

PHP Data Services with PostgreSQL

Sunday, December 7, 2008

If you are using postgreSQL as your backend database and you are wondering how to write a web service exposing data on there, this post will be a good guide for you, PHP Data Services with PostgreSQL.

Using command line to debug your Web Service

Thursday, December 4, 2008

You can actually run your PHP Web Service on the command line. One may wonder what the use of doing that ?

The main use case is that, you can test your service, without having to write a client. It is specially useful, if your are following the code first approach.  You can find the code for actually doing this in one of the WSF/PHP samples. It is in fact the simplest sample of all. The echo_service.php.

Lets have a look at how this becomes possible.

 WSService->reply() function takes an optional string argument . 

1. You can pass the actual XML string expected from the client to the reply function. Then, the service can be executed on the command line to see the actual executed output from an operation.

However, this would work only in cases where you using SOAP Body dispatching or WS-Addressing.

In SOAP Body dispatching case, the XML qualified name of the child element of soap body is used to identify the operation which should be invoked.

In case of WS-Addressing, the addressing action header is used.

2. Lets look at a code sample on implementing this.  This is the echo_service.php sample that comes with WSF/PHP


$requestPayloadString = <<<XML
<soapenv:Envelope xmlns:soapenv="">
     <ns1:echoString xmlns:ns1="">
         <text>Hello World!</text>

function echoFunction($inMessage) {

    $outMessage = new WSMessage($inMessage->str);

    return $outMessage;

$operations = array("echoString" => "echoFunction");

$service = new WSService(array("operations" => $operations));


I have highlighted the important code segments. Note how the Expected soap envelope string is passed to the reply() function as an argument.

3. Now you can execute this service on the command line and get the result.

php echo_service.php

Now you should see the expected output soap envelope after invoking the echoString operation.

4. You can also generate the WSDL for the service on the command line as well. Simply set the reply function argument string to "wsdl" or "wsdl2".


5. Now you can re execute the service and get the wsdl for the service on the command line.

php echo_service.php

This is a very useful feature for debugging your hand coded services  :).

Steps to Convert a SQL Query to a Data Service

Thursday, November 27, 2008

With WSF/PHP Data Service library, you can convert a SQL query to a Data Service very easily in few steps. Here are the steps, described in "Steps to Convert a SQL Query to a Data Service"

5 Facts About WS-Addressing Action in WSF/PHP

Wednesday, November 26, 2008

WS-Addressing Action is used by web services to dispatch the operation for an incoming request SOAP message. This blog "5 Facts About WS-Addressing Action" present you some facts about WSF/PHP API for WS-Addressing.

The Use of SOAP Action with WSF/PHP

Tuesday, November 25, 2008

The SOAP action is mainly used for dispatching of web service operations. This post about "The Use of SOAP Action with WSF/PHP" talks about how SOAP action is presented in a message and how it can be used to write web services and consumers with WSF/PHP.

Data Services - Databases For SOA

Sunday, November 23, 2008

With the adoption of SOA, the more data services are built around existing databases allowing applications to access the data easily as either REST or SOAP with all the WS-* features.. This post about "Data Services - Databases For SOA" talks about the need of data services and tools to implement them.

WS-SecurityPolicy With PHP

Wednesday, November 19, 2008

WS-SecurityPolicy specification defines standards for defining security policies for your web service. This post about "WS-SecurityPolicy With PHP" discusses the approaches you can take in order to associate security policies in to your PHP web service.

Signing SOAP Headers In PHP Web Services

Tuesday, November 18, 2008

Signing meta data of SOAP headers, can be as important as signing the SOAP body which contain the actual data in your business. This post "Signing SOAP Headers In PHP Web Services" talk about how your PHP web service providers and consumers can sign SOAP headers.

Detect Replay Attacks In to Your PHP Web Service

Monday, November 17, 2008

Intruders can make nasty damages to your web services just by using Replay Attacks. So you have to design your services carefully to detect and avoid them. This post "Detect Replay Attacks In to Your PHP Web Service" discusses the possible solutions on detecting replay attacks with PHP web services.

How to contribute to WSF/PHP project

Sunday, November 16, 2008

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 .


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

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


















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.














This should provide you with a patch file.

Step 4.

Go to WSO2 Jira project and select WSF/PHP project



 jira2  Select WSF/PHP project                                            












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










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












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












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.

RESTful URL Mapping in WSF/PHP

In a RESTful design, choose of URLs for web resources are really important. This post about RESTful URL Mapping in WSF/PHP, talks about how you can choose URLs for your resources in a RESTFul manner and How it can be implemented in PHP.

XML Schema Simple Types & How WSDL2PHP Convert Them To PHP

Thursday, November 13, 2008

There are many categorizations of simple types in xml schema. The applications of each of these categories are different from one to other. And the representation of them in PHP are too different. This blog title "XML Schema Simple Types & How WSDL2PHP Convert Them To PHP" explains all about these details.

WSF/PHP Test Cases Explained

Tuesday, November 11, 2008

WSF/PHP comes with a comprehensive set of test cases. It covers the most of the basic/concrete scenarios supported by WSF/PHP. This post titled "WSF/PHP Test Cases Explained" gives you an overview of this test-suite and the scenarios they are covering.

Introduction to reliable messaging part 3

Monday, November 10, 2008

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="">
        <text>Hello World!</text>

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" =>;


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


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" => "",
           "lastMessage" => TRUE));


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.

Sending Custom SOAP Headers in PHP Web Services

Monday, November 3, 2008

There are 2 basic ways of building custom soap headers in your PHP Web Service Client, I.e. With and without WSDL. Check this blog post for more details on how to do follow each of these approach..

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.


oparray["action"] = "";

oparray["reliable"]= TRUE;

client = new WSClient(oparray);


oparray["action"] =""


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

Sending And Handling Faults From PHP Web Service

Thursday, October 30, 2008

Web Services use SOAP fault to send errors back to the SOAP client. This blog about "Sending And Handling Faults From PHP Web Service" talks about how to send and handle soap faults in PHP language.

ScreenCast - How to Consume a Web Service Using WSF/PHP

Wednesday, October 29, 2008

You can watch a Screencast on How to Consume a Web Service Using WSF/PHP from WSO2 Oxygent Tank ( developer portal

WSF/PHP Services Performance test with WSDL Caching

Tuesday, October 28, 2008

WSF/PHP 2.0.0 introduced WSDL caching to optimize the response time of the PHP web services. This blog about "WSF/PHP Services Performance test with WSDL Caching" discuss how to use this feature and shows the result of a performance test done with and without WSDL caching to demonstrate the performance improvements with the WSDL caching.

Introduction to Reliable Messaging with WSF/PHP

Monday, October 27, 2008


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="">
   <soapenv:Header xmlns:wsa="">
      <wsrm:CreateSequence xmlns:wsrm="">
         <wsrm:AcksTo xmlns:wsrm="">
            <wsa:Address xmlns:wsa=""></wsa:Address>
         <wsrm:Offer xmlns:wsrm="">

2. Service responding with a CreateSequenceResponse message.

<soapenv:Envelope xmlns:soapenv="">
   <soapenv:Header xmlns:wsa="">
      <wsa:RelatesTo wsa:RelationshipType="" xmlns:wsa="">urn:uuid:6dbfe9a0-304f-415e-91d1-49d2993bcf56</wsa:RelatesTo>
      <wsrm:CreateSequenceResponse xmlns:wsrm="">
         <wsrm:Accept xmlns:wsrm="">
            <wsrm:AcksTo xmlns:wsrm="">
               <wsa:Address xmlns:wsa="">http://localhost/samples/reliable/echo_service_rm.php</wsa:Address>

3. Client sending the sequence Message

<soapenv:Envelope xmlns:soapenv="">
   <soapenv:Header xmlns:wsa="">
      <wsrm:Sequence soapenv:mustUnderstand="1" xmlns:wsrm="" xmlns:soapenv="">
         <wsrm:MessageNumber xmlns:wsrm="">1</wsrm:MessageNumber>
         <wsrm:LastMessage xmlns:wsrm=""/>
      <ns1:echoString xmlns:ns1="">       
         <text>Hello World!</text>   

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="">
   <soapenv:Header xmlns:wsa="">
      <wsrm:Sequence soapenv:mustUnderstand="1" xmlns:wsrm="" xmlns:soapenv="">
         <wsrm:MessageNumber xmlns:wsrm="">1</wsrm:MessageNumber>
         <wsrm:LastMessage xmlns:wsrm=""/>
      <wsrm:SequenceAcknowledgement soapenv:mustUnderstand="0" xmlns:wsrm="" xmlns:soapenv="">
         <wsrm:AcknowledgementRange Lower="1" Upper="1"/>
      <wsa:RelatesTo wsa:RelationshipType="" xmlns:wsa="">urn:uuid:8e275ba1-b34b-49c1-92fa-ce86782ff803</wsa:RelatesTo>
      <ns1:echoString xmlns:ns1="">       
         <text>Hello World!</text>   

5. Client send the SequenceAcknowledgement message to the service.

<soapenv:Envelope xmlns:soapenv="">
   <soapenv:Header xmlns:wsa="">
      <wsrm:SequenceAcknowledgement soapenv:mustUnderstand="0" xmlns:wsrm="" xmlns:soapenv="">
         <wsrm:AcknowledgementRange Lower="1" Upper="1"/>


6. Now the service sends back a TerminateSequence Message.

<soapenv:Envelope xmlns:soapenv="">
   <soapenv:Header xmlns:wsa="">
      <wsrm:TerminateSequence xmlns:wsrm="">

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.

WSF/PHP WSDL Mode - Handling XML Schema Arrays

Saturday, October 25, 2008

This post "WSF/PHP WSDL Mode - Handling XML Schema Arrays" talks about how you deal with XML Schema arrays when you write web services in WSDL mode with WSF/PHP.

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

Thursday, October 23, 2008

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

<soapenv:Envelope xmlns:soapenv="">
      <ns1:echoString xmlns:ns1="">
         <text>Hello World!</text>


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  ""

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"

<soapenv:Envelope xmlns:soapenv="">
      <ns1:echoString xmlns:ns1="">
         <text>Hello World!</text>

In SOAP 1.2

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

2. SOAP envelope namespace uri is "".

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.

WSDL Generation From PHP - Using Different Names in WSDL and PHP Code

In Generating WSDL from PHP code, you may need to generate schema types with different names to the corresponding PHP classes. This post describes how you can do that.

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

Tuesday, October 21, 2008

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" />


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.

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

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.

Tips on avoiding common WSF/PHP installation issues.

Here are some useful tips avoid common fit falls in installing WSF/PHP.

1. Often users complain that When the run the sample clients, they see the response

"ERROR, WS Client not Found'.

This is often due not setting the wsf.home entry correctly. Make sure to set wsf.home directory to point to wsf_c  directory if your are on windows or using pecl installation with WSF/C library installed separately.

Another reason for this is not adding the wsf_c/lib directory to PATH environment variable if you are on a windows system.

2.  WSDL Generation and WSDL mode does not work.

This is often due to you not having added the scripts folder found inside the wsfphp distribution to the php.ini's include path entry.

3. Compile WSF/PHP using source gives errors.

This could be due to two issues.

1. First you need to have installed the dev-libraries of PHP, Libxml2 and OpenSSL.

2. Incorrect configure options provided to the configure script.

          Often you do not need to provide any options to the configure script since it is written to work as

./configure, make , make install sequence.

RESTful PHP Web Services - Book

My book on RESTful PHP Web Services is now available for download from Packt Publishing.

What you will learn from this book

  • Basic concepts of REST architecture
  • Consuming public REST-style services from your PHP applications
  • Consuming RESTful web services, such as those from leading APIs such as Flickr, and Yahoo Web Search
  • Making your own PHP applications accessible to other applications through a RESTful API
  • REST support in the popular Zend framework
  • Debugging RESTful services and clients
  • A case study of designing a RESTful PHP service from the ground up, and designing clients to consume the service

It is also note worthy that there is a dedicated appendix chapter in this book on using WSO2 WSF/PHP.

Coding Schema Inheritance in PHP

This post "Coding Schema Inheritance in PHP" describes How inheritance is used in XML Schema and how it is mapped to PHP code from wsdl2php tool in WSF/PHP.

How to install WSF/PHP in Debian/Ubuntuu Systems from scratch

Monday, October 20, 2008

In the post WSF/PHP from the scratch Dinesh explains how to install WSF/PHP in a Debian or Ubuntu System from the scratch. He starts the post with a how to on installing and configuring Apache and PHP in a fresh debian machine and then install WSF/PHP on top of them. If you are finding help to install WSF/PHP on a debian machine, this post will be really useful.

How to use Attachment Caching with WSF/PHP

WSF/PHP 2.0.0 has the support for caching attachments ( writing to a file ). This effectively reduces the amount of memory used when sending and receiving attachments and its specially useful, if your application requires to send or receiving a very large file in the scale of megabytes.

WSF/PHP adds two php.ini entries in order to allow attachment caching.

1. wsf.attachment_cache_dir


wsf.attachment_cache dir is the location where the received attachments will be saved.

wsf.enable_attachment_caching option enables attachment caching.

By default, attachment caching can be done only for attachments larger than 1 MB.

Lets see a code sample on how to use this. This is a simple php service, which reads a binary file and send it to the client as an  MTOM attachment.


ini_set("wsf.enable_attachment_caching", 1);

function sendAttachment($msg)
$responsePayloadString = <<<XML
        <ns1:download xmlns:ns1="">
                <ns1:image xmlmime:contentType="image/jpeg" xmlns:xmlmime="">
                    <xop:Include xmlns:xop="" href="cid:myid1"></xop:Include>

    $responseMessage = new WSMessage($responsePayloadString,
            array( "attachments" => array("myid1" => "../resources/large_image.jpg"))); 
    return $responseMessage;   

$operations = array("download" => "sendAttachment");

$service = new WSService(array("operations" => $operations, "useMTOM" => TRUE));



Now in above code, I have highlighted the important code pieces.

1. The php ini settings at the top of the code where the attachment_cache_dir is set and attachment caching is enabled.

ini_set("wsf.enable_attachment_caching", 1);

2. Setting of a fake content id to which the actual attachment is assigned.


3. Instead of setting binary attachment as an string in the attachment array, we should set the actual path to the file.

array("myid1" => "../resources/large_image.jpg")

Thats all you need to do to get attachment caching working. The same technique can be used for the client as well. It will be consuming lot less amount of memory.

Demo on Consuming Flickr, Yahoo and Amazon Search Web Services

Sunday, October 19, 2008

The Mashup Search Demo, demonstrates the use of publicly available web services (flickr, yahoo, amazon) to create a search mashup in your web site. This blog is a guide to follow the implementation of this demo.

DEMO on a SOAP and REST Client with PHP

Friday, October 17, 2008

Amazon ECommerce service is available in both SOAP and REST forms. This guide shows you how to consume the service using either form with the help of a demo application.

Using Open SSL to manage Your Keys

When it comes to WS-Security, for most of the operations, you will need to have either a certificate, or a key or both. Or you will need to provide a key store. WSF/PHP uses Open SSL library underneath to build WS-Security. Therefore knowing how to work with Open SSL can be really useful.

Lets go through some of the important commands you need to know to effectively get work done using Open SSL.

1. Generating a Certificate using Open SSL.

When generating a certificate, you have to decide whether you want an encrypted key or not. If you select the encrypted key option, your key will be protected by a passphrase.  This adds more security to your key since it will be difficult for some one stealing your key to use it. How ever you will need to provide this passphrase, every time you use the key. A self signed certificate is used to sign other certificates.

Use the command

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

These options tells openssl to generate key length 1024  bits which is valid for 365 days and put both private key and certificate to a file named mycert.pem.


Now you will be prompt to answer a number of questions and then OpenSSL will generate you a self signed certificate.  Now if you open the mycert.pem you will see both the private key and the certificate stored there. If you remove the -nodes option, you will be asked to provide a passphrase.

2. Generating a private key and a matching public key using RSA algorithm.

It is sometimes necessary to generate the private key and public keys separately.

You can generate an RSA public key using the option genrsa.

openssl genrsa -out mykey.pem 2048

This generates a rsa private key with 2048 bits.

Using rsa option, you can get the corresponding public key.

openssl rsa -in mykey.pem -pubout

3. Creating a PKCS12 Keystore and adding keys to it.

openssl pkcs12 -export  -out mycert.pfx -in mycert.pem  -name "My Keystore"

This command generates a PKCS12  key store by exporting the above generated certificate. Here you will be asked for a passphrase as well.

XML Signature

Thursday, October 16, 2008

XML signature is used in WS-Security to sign SOAP messages. Here is a blog post describing XML Signature.

Installing WSF / PHP with Wampserver Article in French

You can find a really nice article on installing WSF/PHP with WAMP in French Language from here. If you want the English translation using Google translater access from here.

Demo on Providing PHP Web Service with Username Token

I wrote a blog on Calender DEMO which shows a real world use of the user name token in web service authentication. It describes how you declare different policies per operation in a WSDL and provide authentication information from a callback function.

Fetching song lyrics

LyricWiki is an excellent free service providing song lyrics. A la wikipedia for song lyrics. Find out how easy it is to access this service using WSF/PHP.

How to build PHP from source

Wednesday, October 15, 2008

It is an interesting thing to build PHP source on a Windows Platform. It is extremely useful to build PHP source with various options specially if you wish to write a PHP extension. Here are some interesting tips on how you can build PHP source on a windows platform.

First you need to download the following dependencies.

1. You need to have visual studio or windows platform SDK install on you machine in order to have the required compiler and build tools.

2. You need to download the PHP build dependencies.

These include

1. Binary tools - Essential

2. Libxml2   - Optional

3. Iconv Optional

4. Zlib   - Optional

5. Apache or other web server that you intend to build modules.

6. PHP Source  - Essential

7. bindlib-cvs-vc8  - Essential


Most of these tools can be downloaded from here.

Once you have downloaded these tools, you are ready to build PHP from source.

First unzip all these tools to a directory. 










Next, open visual studio command prompt and add binary-tools\bin directory to the path.






Now, go to the PHP source extract directory and type,


Then run

cscript /nologo configure.js --help
















You will see a large number of options as shown above.

Next open the config.nice.bat file located in the php source directory and add necessary configure options for your build

Here are my configuration options

cscript /nologo configure.js  "--with-extra-includes=E:\phpbuild\bindlib-cvs-vc8\include;E:\Apache22\include;E:\phpbuild\iconv-1.9.2.win32\include;E:\phpbuild\libxml2-2.6.30.win32\include;E:\phpbuild\zlib-1.2.3.win32\include"


"--enable-debug"  "--enable-apache2-2handler" %*

Here I am using the option --with-extra-includes to specify the include paths of the dependency libraries.  Similarly --with-extra-libs is used to specify the library path.

I use the options --enable-debug to make it a debug build.

Now run config.nice.bat file.

Next you can try nmake on the command line  and it will build the PHP Source.

Bridging the Gap Between Enterprise and Web Applications

WSF/PHP allows web applications to integrate with enterprise applications using the Web Services. Here is a blog post talks about Bridging the Gap Between Enterprise and Web Applications using WSF/PHP.

Writing a Simple REST and SOAP Service With PHP

Friday, October 10, 2008

WSF/PHP enables you to write a web service in a single script and expose it as both SOAP and REST services. Here is a simple HowTo on creating a Web Service which handle both REST and SOAP requests.

WSClient WSDL Mode With Array Based API

Wednesday, October 8, 2008

In WSDL mode you have two APIs. One is Class based API which is more common and the other is Array Based API. Sometime it is easy to use Array Based API over the class based API. I'm explaining this with an example in this blog entry.

Test your SSL SOAP Client with an Online Service

Tuesday, October 7, 2008

Do you know WSF/PHP Demo Site services are deployed as HTTPS Services as well. You can use these services to test WSClient. This post give you a little overview of this and a sample client code to call the service.

Invoking WSF/PHP Web Services Through Proxy

Monday, October 6, 2008

If you want to invoke an external web service through PHP and you are behind a proxy server, you have to configure the proxy in your client. This blog Invoking WSF/PHP Web Services Through Proxy describes how you do it with WSF/PHP.

Data Services with SQLite in PHP

Sunday, October 5, 2008

If you want to expose you SQLite Database as a Web service, Here is a blog "Data Services with SQLite in PHP" on how to do it.

MSSQL(Microsoft SQL) Data Services In PHP

Saturday, October 4, 2008

If you are using MSSQL as the back-end database for you PHP program this blog about Providing MSSQL Data Services in PHP will be a nice read.

XPath in SimpleXML

Wednesday, October 1, 2008

This is a blog about XPath in SimpleXML which explain How you going to use XPath in the SimpleXML environment. This is not directly related to Web Services . But there is no doubt XML traversing is a big part in a web services code. So I hope PHP Web Services developers find this post really useful.

Online Tools for PHP Web Services Developers

Sunday, September 28, 2008

You can find an overview of the tools hosted in the PHP Demo Site in this post.

REST Framework for PHP

Saturday, September 27, 2008

I have been blogging about WSF/PHP 2.0 being a comprehensive REST framework. Now it is available for you to download.

If you want to design services from scratch, WSF/PHP would be a very good choice, because it provides a natural mapping form design to implementation.

Also, given the fact that this is an extension written in C, it would also provide you with better performance, compared to other REST frameworks purely written in PHP.

RESTful CRUD Data Services Demo

Here is a live demo on RESTful Data Services implemented with WSF/PHP. I wrote a blog about this Demo explaining how you give semantic to the Http Verbs to manipulate (Do CRUD operations on) Resources in RESTful way.

Http Authentication for SOPA Messages in PHP - 2 Minutes Introduction

Thursday, September 25, 2008

Yesterday I wrote about authenticating users using Username token which is a more SOA friendly way of doing authentication. Because it is handled in Message level and clearly defined in WS-Security Specification.

But if you want to do Http Basic Authentication you can still use WSF/PHP as your client. Here is a blog How you send Basic Authentication information with your SOAP message in PHP. Note that here authentication is handled in trasport layer. So this approach is only valid if you are using HTTP transport which is the most common transport to use in web services.

Authenticate using Username Token from PHP - 2 Minutes Introduction

Tuesday, September 23, 2008

Username token is the most simple scenario described in WS-Security specification. It is used to authenticate users from their SOAP request messages.

The blog "Authenticate using Username Token from PHP - 2 Minutes Introduction" give you quick tutorial how you can implement this in PHP using WSF/PHP.

Webinar - Introducing Enterprise Web services with WSO2 WSF/PHP 2.0.0

Monday, September 22, 2008

WSO2 WSF/C product stack lead Selvaratnam Uthaiyashankar is doing a *FREE* Webinar on “Introducing Enterprise Web services with WSO2 WSF/PHP 2.0.0” at 11.00 AM (US Mountain Time) on 23rd September 2008.

You can register from this link. Note that you don't need any registration fees.

Send Binary With Web Services in PHP - 2 Minutes Introduction

If you want to send binary in web services, you have several options. You can use either base64 encoded strings or MTOM, SWA binary optimized protocols. Here is a very quick introduction on how you can implement it in your application.

WSDL2PHP 2 Minutes Introduction

In .Net, Java or C before you developing a web service consumer or a provider you have tools to generate a skeleton code from the WSDL. So you only to concentrate on your business logic as all the WSDL related work is handled by this generated code.

WSDL2PHP is the tool to do the same in PHP. Have a look at this tutorial to learn how to use it in your application.

SOA Way of Writing PHP

Thousands of web developers around the world use PHP to develop their web applications. As SOA emerges, the enterprise world is moving towards web services more than just web applications. But PHP is slow to used in implementing SOA. This blog titled 'SOA Way of Writing PHP' is study of why you should use SOA in your enterprise application and how to implement it in real world.

Integrating PHP CMS systems with other applications

Friday, September 19, 2008

Here are some interesting thoughts on how to integrate PHP CMS system with other enterprise applications.

Video - WSF/PHP in Enterprise Applications

Thursday, September 18, 2008

Shankar who is the manager of the WSF Framework projects including WSF/PHP, explaining the Real world use of the WSF/PHP specially in the enterprise space.

Do REST in PHP - PHP RESTful Data Services

Can you do PHP Data Serivces in REST style with WSF/PHP 2.0.0. Yes certainly you can do it.

Check out this demo about 'RESTful School' and see how can map unique urls to each piece of data you have.

Check "Do REST in PHP - PHP RESTful Data Services" for a guideline of the demo.

Simplest Approach to Enterprise Grade Web Services

Are you bored with spending lots of time and money writing web services? Are you bored dealing with complex API's provided by Java and .Net based web services platforms? These are the things that we worry every day when we want to bring our software solutions to the outside world as standard services.

Now we are moving to a new era of Web Services with WSF/PHP as a platform for developing enterprise grade web services with the minimal effort from the programmer. Now lets look at what are tools required to build a enterprise solution using Web Services.

Obviously the first requirement is the ability to create and consume web services. WSF/PHP has this capability in the simplest form possible. You can read more about how to create and consume web services in the online documentation of WSF/PHP. This includes the creating services from WSDL and creating services manually. Also for the client side you have the option of building the client manually as well as using the WSDL.

But creating and consuming web services is only a small part of your overall solution. At the beginning you may think that "who cares about security". But when your application grows I can guarantee you will feel the need for security. But there is nothing to worry as WSF/PHP can cater for all your web services security requirements. As the service writer you don't have to worry about the details of complex WS-Security mechanisms underneath. That is the best part of the story.

If you want more than the delivery guarantees of TCP protocol and want the message level reliability, WSF/PHP can use the WS-ReliableMessaging delivery guarantees.

Also WSF/PHP comes with a nice way to convert all your data to web services very easily. Now you don't have to write services manually to expose your existing data to the world. WSF/PHP Data services can do this for you in very few easy steps.

WSF/PHP comes with two very distinctive features that you won't find in any other web services platform. Enterprise readiness and ease of use are these two distinctive features. So if you want to develop enterprise grade web services with the minimal effort try WSF/PHP and feel the difference.  

Debugging PHP Web Services

I wrote a blog on some of the tips of how to debug web service client and services. It would be useful to you if you are getting started with WSF/PHP.

Installing WSF/PHP in windows

Tuesday, September 16, 2008

WSF/PHP is a new era for web services with its ease of use and all the cool features. To unveil this new world of web services you need to get started in some way. I have chosen the hard way and decided to build it from the scratch. I have blogged about my first experience with WSF/PHP. In this I have explained how to build and configure WSF/PHP under windows.

PHP Data Services With WS-Security

When it come to a PHP application with WS-Security, you should be using WSF/PHP somewhere. Similarly with the new Data Services library WSF/PHP become the only option to host Data Services with WS-Security.

Read my blog post on Data Services with WS-Security where I used an online DEMO application to demonstrate the use of WS-Security in Data Services.

Implementing REST Client and Services Using WSF/PHP

Monday, September 15, 2008

WSF/PHP 2.0.0 supports implementing REST Services and clients using HTTP Methods POST,GET,DELET, and PUT. It addition, it allows custom URL mappings for service operations.

You can find more details on implementing REST client and Services using WSF/PHP here.

Code First Approach of Developing Services with WSF/PHP 2.0

WSF/PHP comes with many new features + feature enhancements including improvments for WSDL Generation. WSDL Generation is a core module of the WSF/PHP which allows developers to use 'Code First Approach' to develop web services.

I have blogged about existing features + new features avaialble in the WSF/PHP supporting the code first approach of developing services. If you prefer this approach you will find this post really helpful.

Only PHP Library for Creating Both SOAP and REST Services

WSO2, the open source SOA company, today announced the availability of the WSO2 Web Services Framework for PHP (WSF/PHP) 2.0. WSF/PHP is the industry's only PHP scripting language library that enables developers to create and consume both SOAP and REST Web services -- with the security and reliability required for an enterprise service-oriented architecture (SOA).

WSF/PHP 2.0 adds significantly expanded REST functionality, new Data Services, greater interoperability, and extended security. With WSF/PHP 2.0, developers now have a comprehensive framework for deploying PHP services that meet the strict enterprise SOA standards implemented by corporations and governments worldwide.

WSF/PHP 2.0 is part of the WSO2 family of Web Services Framework (WSF) products designed to support enterprises' heterogeneous SOAs. Other WSO2 WSF products include WSF/Ruby, WSF/Perl, WSF/Java, WSF/JavaScript, and WSF/Spring. With the WSF family, enterprises' diverse developer communities have the functionality they need to create Web services in their language of choice.

"WSO2 exists to enable heterogeneous SOAs, and WSF/PHP 2.0 is an important part of that mission. Through WSF/PHP 2.0, enterprises can tap an expansive community of PHP developers by giving them the first comprehensive framework for easily creating both SOAP and REST services," said Dr. Sanjiva Weerawarana, CEO of WSO2. "With our new Data Services and expanded interoperability, WSF/PHP 2.0 also provides a critical bridge between tens of thousands of PHP Web applications and the many enterprise data sources, applications and services driving today's enterprises."

WSF/PHP 2.0 Development, Interoperability and Security Enhancements

With full support for REST, SOAP, and WS-* specifications, WSF/PHP lets a single service be exposed both as a SOAP-style and as a REST-style service using a simple PHP-friendly programming model. WSF/PHP 1.0 provided a REST API along with support for SOAP 1.1 and 1.2, WSDL 1.1 and 2.0, and SOAP Message Transmission Optimization Mechanism (MTOM). WSF/PHP 2.0 adds a comprehensive REST framework featuring custom Uniform Resource Identifier (URI) mapping -- making it easy and intuitive to map a REST API into PHP when creating a Web service.

WSF/PHP 2.0 facilitates Web service creation for the large majority of PHP Web applications that rely on databases. The new WSF/PHP Data Services solution lets developers take data in LAMP(1), WAMP(2), and other PHP-based systems and expose it as a Web service with full WS-* support. Key features include a dbs2php converter tool, and support for multiple database engines, nested queries, and WSDL generation.

Extended interoperability in WSF/PHP 2.0 makes it easier for developers to seamlessly integrate PHP applications with those based on other enterprise platforms. WSF/PHP 2.0 offers much stronger support for the latest WS-* standards, as well as increased testing against Microsoft .NET, the WSO2 WSAS, Axis2/Java, and other J2EE implementations.

    WSF/PHP enterprise security and reliability includes the support
for WS-Security, WS-SecurityPolicy, and WS-ReliableMessaging available
with WSF/PHP 1.0. Version 2.0 of WSF/PHP adds capabilities in four

-- Replay detection tracks whether a message is fresh or has been
previously sent, preventing replay attacks that can lead to
denial of service.

-- WS-Trust for issuing, renewing, and validating security tokens
ensures trusted relationships.

-- WS-SecureConversation support allows a series of messages (a
conversation) to be protected by a single session key,
improving efficiency of the operation.

-- Support for the Public Key Cryptography Standards (PKCS) makes
it possible for services written in WSF/PHP to handle multiple
client x509 certificates simultaneously, further improving

Other development and performance enhancements in WSF/PHP 2.0 include:

    --  Increased WSDL support includes tools, such as wsdl2php for
contract-first development of services and clients; the
ability to generate WSDLs for WSF/PHP Web services scripts;
and proven support for a range of WSDL styles, including
support for advanced schemas such as extensions and

-- Policy-driven design provides users with a maximum level of
control by allowing developers to configure the behavior of
services using policies.

-- Binary data capability gives users a choice between sending
and receiving binary data as attachments using either MTOM or
a SOAP message with attachment (SwA). MTOM in version 2.0 has
been optimized through caching, enhancing performance.

-- Expanded deployment models for WSF/PHP 2.0 include several
platforms -- notably Linux, Windows, and Solaris -- as well as
seamless integration with Apache and Microsoft Internet
Information Services (IIS) Web servers.

-- Enhanced stability to ensure high availability and

Zend Core Support Featured at ZendCon

With version 2.0, WSF/PHP has been tested and proven to run with Zend Core, Zend's tested, certified and supported version of PHP, which has been widely adopted by enterprises for their production PHP environments. WSF/PHP 2.0 is being launched in conjunction with ZendCon 2008; the Zend/PHP conference runs September 15-18, at the Santa Clara Convention Center in Santa Clara, CA. WSO2 will demonstrate WSF/PHP 2.0 at the Microsoft ZendCon booth.

"Zend and WSO2 are mutually dedicated to serving the diverse needs of PHP developers with world-class open-source software for implementing Web services," said Andi Gutmans, CTO and co-founder at Zend Technologies. "By bringing support for both enterprise-oriented WS-* and REST Web services to our managed PHP production environment, WSO2 joins us in empowering the developers supporting more than 20 million PHP websites with unprecedented flexibility for delivering enterprise-class Web services."

WSF/PHP 2.0 Webinar

WSO2 will present a free webinar, "Introducing Enterprise Web Services with WSO2 WSF/PHP 2.0," which will review how to take advantage of the new REST functionality and WSF/PHP Data Services support. The webinar will run from 9:00-10:00 a.m. Pacific on Tuesday, September 23, 2008. Presenting the webinar will be Selvaratnam Uthaiyashankar, a WSO2 software architect and lead developer of the WSO2 Web Services Frameworks. For more information, visit:

Availability and Support

The WSO2 Web Services Framework for PHP 2.0 is available for download today. As a fully open source solution released under the Apache License 2.0, it does not carry any software licensing or subscription fees. WSO2 offers a range of service and support options for WSF/PHP 2.0. These include support subscriptions, training, consulting, custom development and development support. For information on service and support packages, visit

About WSO2

WSO2 is the open source SOA company founded by pioneers in Web services and the Apache Software Foundation Web services community. The company delivers the only tightly integrated, entirely open source middleware stack that is optimized for SOA. The WSO2 products address the core components of SOAs: service creation, connection, composition and governance. The company is backed by Intel Capital and maintains operations in the United States, United Kingdom and Sri Lanka. For more information, visit

(1)LAMP: open source Web platform consisting of Linux, Apache, MySQL, and PHP

(2)WAMP: Web server package containing Windows, Apache, MySQL, and PHP

Trademarks and registered trademarks are the properties of their respective owners.

Source: WSO2

WSO2 Web Services Framework for PHP v2.0.0 Released

Friday, September 12, 2008


WSO2 WSF/PHP version 2.0.0 was released today. It comes with a lot of new features. In addition to the that many bug fixes have been done since the previous release.

Following are some of the key features and changes for this release extracted from the release  note.

Key Features

1. Client API to consume Web services
      * WSMessage class to handle message level options
      * WSClient class with both one way and two way service invocation support
      * Option of using functions in place of object oriented API with ws_request

2. Service API to provide Web services
      * WSMessage class to handle message level options
      * WSService class with support for both one way and two way operations
      * Option of using functions in place of object oriented API with ws_reply

3. Attachments with MTOM
      * Binary optimized
      * Non-optimized (Base64 binary)

4. WS-Addressing
      * Version 1.0
      * Submission

5. WS-Security
      * UsernameToken and Timestamp
      * Encryption
      * Signing
      * WS-SecurityPolicy based configuration
      * WS-Secure Conversation

6. WS-Reliable Messaging
      * Single channel one way and two way reliable messaging

7. WSDL Generation for Server Side
      * WSDL generation based on annotations and function signatures, and
        serving on ?wsdl or ?wsdl2 requests

8. WSDL mode support for both client and server side
      * Write services and client based on a given WSDL
      * WS-Addressing and WS-SecurityPolicy is supported in WSDL mode
      * MTOM is now supported with WSDL mode
9. REST Support
      * Expose a single service script both as SOAP and REST service

10. Provide easy to use classes for common services
      * Consume some well known services such as Yahoo search and Flickr
        and Amazon services using predefined classes

11. wsdl2php.php script. This script can generate PHP classes for services
    and clients for a given WSDL to be used with WSDL Mode .

12. Data Services API
    PHP Data Services API that enables exposing database queries as web services.


Major Changes Since Last Release
* Added PKCS12 Keystore Support
* Added Secure Conversation Support
* Added Replay Detection Support
* Contract First Web Services support for MTOM
* SWA ( Soap With Attachments ) Support added
* MTOM Attachment caching support added
* HTTP Chunking support added
* REST API Improved to support HTTP verbs GET,DELETE,PUT and POST
* New PHP Data Services Solution
* WS-RM 1.1 added
* Many Bug Fixes


As you can see, A lot of new features have been added since that last release. It is a feature complete and therefore we are calling it version 2.0.0.

We welcome you to try out this latest release of WSF/PHP.

Developing WSF/PHP Webservices With Contract First Approach - 2 Minutes Introduction

Monday, September 8, 2008

Are you finding a quick guide to develop a web service starting from a WSDL (contract first approach). Have a look at my blog on Developing WSF/PHP Webservices With Contract First Approach - 2 Minutes Introduction

PHP DataServices 2 Minutes Introduction

Saturday, September 6, 2008

Here is a very quick introduction to the DataServices and the PHP DataSerivces API, PHP DataServices 2 Minutes Introduction. PHP DataServices library will be released with the WSF/PHP 2.0 version within next couple of week. If you are really hurry to test this library, go and get it from the DataService demonstration page from PHP Web Services DEMO site.

WSF/PHP WSDL Generation 2 Minutes Introduction

Friday, September 5, 2008

If you want a quick look at how to generate a WSDL from a PHP Script Read my blog on WSF/PHP WSDL Generation 2 Minutes Introduction

WSF/PHP Articles and Tutorials

Monday, September 1, 2008

Here are some of the tutorials and articles written about WSF/PHP.

Blog from WSO2 WSAS Developers

Sunday, August 24, 2008

If you are really interested in JAVA web services and like to know its applications in enterprise level Here a great NEWS. Developers of WSO2 Web Services Application Server (WSO2 WSAS) have started a Blog WSO2 WSAS Blog to keep you update about the WSAS project and NEWS generally on SOA, Web Services, WS-* Stack. You will surely find this place really useful in addition to the resource you can find in WSO2 Projects Community Portal - Oxygen Tank.

Howto Build Custom SOAP Headers in WSDL Using Axis2/C and WSF/PHP

Thursday, August 21, 2008

WSF/PHP latest trunk has the support for sending and serving custom headers in the WSDL Mode. Read this blog about Howto Build Custom SOAP Headers in WSDL Using Axis2/C and WSF/PHP for more details about the API and how you would declare custom headers in a WSDL.

Next WSF/PHP Release is Almost Ready

Tuesday, August 19, 2008

We are almost done. Today, I had a look into the issue tracker, and there are only about four issues pending. That is covering lots of ground.

We should have the next WSF/PHP pack released by mid of next month.

Send Binary in SOAP with WSF/PHP 1.3.2

There are different methods you can send binaries in a SOAP message. The blog "Send Binary in SOAP with WSF/PHP 1.3.2" describes these methods in general and how you can implement each of these approach in WSF/PHP 1.3.2

Short note for Web Services Security API in WSF/PHP 1.3.2

Sunday, August 17, 2008

I wrote a little short note on how you can use WS-Security with WSF/PHP 1.3.2 in here.

REST Frameworks for PHP

Zend Framework has client and server classes for REST. WSO2 WSF/PHP too has comprehensive support for REST, both client and services.

If your requirements are simple and you are just starting to use REST services, Zend Framework would be a good choice to start with. But if you are going form design to implementation and your application is of enterprise grade, then you have to consider WSO2 WSF/PHP. WSF/PHP is designed in such a manner that you can map your resource design, along with HTTP verb mapping and custom URI mapping to business operations with minimal effort.

PHP Data Services - Integration to next level

Saturday, August 16, 2008

Related to my yesterday's post on integration, have a look at this post, to get an understanding on getting data as Web services to really work in the real world

The right way to Integrate

Friday, August 15, 2008

Do you integrate you PHP application with other applications out there? Is your portal running with PHP and you leverage other third party applications to make your PHP application rich? And what are the technologies you use there?

Web services has been used for some time now to solve integration problems, and PHP can use the same technologies. Most application, including Software as a Service (SaS) applications provide Web services APIs, both SOAP and REST. And WSF/PHP form WSO2 provide a very strong set of APIs for this.

WSO2 itself has an array of PHP based Web applications. The corporate Web site, developer portal web site as well as an array of other applications that are internal but are integrated to the .com and .org site used an array of PHP applications. And they leverage Web services, and WSF/PHP when it comes to integrate across the various applications. As an example we talks to Jira based support system using Web services API and integrate that to Drupal based developer sites user accounts.

So, not only that WSO2 develop these great products and contribute those to the community, but WSO2 itself use them in production. You can too...

Encrypt and Sign your SOAP messages in PHP

Thursday, August 14, 2008

I wrote a blog about How to Encrypt and Sign your SOAP Messages in PHP. You can find out the two basic choices you have in securing soap messages + some links on how to develop them.

Make your Wordpress Blog a Web Service in Few Steps

Sunday, August 10, 2008

I wrote a simple guide in here about how to create a Web Service from a Wordpress blog using WSO2 PHP DataServices library.
It doesn't matter what you have is Drupal, Wordpress or Joomla, You can still follow this guide and understand the concept and use of the DataService Library. Without doubt it will assist you to create a web serivce from your existing database strcture without much effort.

Installing wsf/php in a third party hosting environment

Wednesday, August 6, 2008

If you have a third party hosting environment and you want to use wsf/php extension, you have to set to deploy the PHP as cgi-based and not through traditional mod_php. That way you will be able to use custom php.ini and configure wsf/php installation. Make sure to check whether your hosting service have capability to deploy cgi-based php and any documentation for that. For an example dreamhost provides following documentation for that.

There may be some hosting environments (Here I mean hosting services deployed php in linux based systems) that you are not have permission to read root directories. So in such cases you have to set the extension_dir entry in the php.ini relative to the cgi-bin directory in your document root. But wsf/php 1.3.2 and lower versions having a problem of not loading wsf.home directory when you are using WSClient class. But it works well for WSService by default.

You can solve this problem by putting the following code right before you use WSClient.

$script_dir = dirname($_SERVER['PHP_SELF']);
$htdocs_dir = '.'.preg_replace('/[^\\/']+/, '..', $script_dir);
$cgibin_dir = $htdocs_dir.'/cgi-bin';


For an example if you put the above code to the echo client in sample directory it would be like,

$requestPayloadString = <<<XML
<ns1:echoString xmlns:ns1=><text>Hello World!</text></ns1:echoString>


try {

$script_dir = dirname($_SERVER[
$htdocs_dir =
".".preg_replace("/[^\\/"]+/, "..", $script_dir);
$cgibin_dir = $htdocs_dir.


$client = new WSClient(array( to =>
"" ));

$responseMessage = $client->request( $requestPayloadString );

printf(Response =
"%s <br>", htmlspecialchars($responseMessage->str));

} catch (Exception $e) {

if ($e instanceof WSFault) {

printf(Soap Fault:
"%s\\n", $e->Reason);
} else {
printf(Message = "%s\\n