Approaches you can select in developing your PHP Web Service

Wednesday, January 9, 2008

When you start writing a Webservice you will have to choose one of the two popular approaches of developing a Webservice, i.e. code-first approach or contract-first approach.

In code first approach, initially you will code the interfaces you want to publish as the web service even with the business logic inside. Then you generate WSDL which become the contract (at least the major part of the contract) based on the written code.

Whereas In contract-first approach, you first start with writing the WSDL and then you generate codes for the programming language to provide and consume the service. From these two approaches you need to selectively choose the best one for you based on your problem environment. You may find some good explanation of this topic by Ajith Ranabahu in here.

WSO2 Web Service Framework for PHP
give you the maximum support for both kind of approaches.

If you already have written the service code and deployed it, you can get generated the WSDL by just adding "?wsdl" to the end of service URI. That is for the people who uses code-first approach.

If you already have the WSDL, then you will be able to use the WSDL mode API to write the service enabling the contract-first approach. This really minimize the effort and time you have to spend in writing a service, although it is encouraged to use the XML in/out mode API, which no doubt gives you more performance.

2 comments:

Sebu said...

Hello,

do you know where I can find an example of the "XML in/out mode API"?

One problem with WSO2 I have: the SOAP style "document literal (wrapped)" used by .NET SOAP Servers is not documented in WSO2/PHP.

Sebastian

Dimuthu said...

Hi Sebastian,
You can find an example of using XML in/out API in the WSF/PHP manual at here . (for a link to the complete manual, please follow this link.

Yea, There are some blankspace to filled in the manual about using WSDL mode. (at least some examples of different WSDL styles). But the example in the manual actually uses a Doc-lit WSDL. Doc-lit (wrapped) can also be used in similar way.

Dimuthu