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.

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.

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.

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.

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.

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.

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

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.

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

2.wsf.enable_attachment_caching

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.

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.

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.

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.

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.

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.

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.

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.

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.