I have been working to get WSO2 WSF/PHP 2.0.0 to work with the SecureCalculatorApp example web service provided with NetBeans 6.1. I want to be able to call a secure web service created with NetBeans 6.1′s user interface from an application written in PHP. SecureCalculatorApp example provides a really good starting point for a simple interoperability test.
NetBeans’s user interface for managing the security etc. settings of a web service is pretty simple and lacks a lot of the control for the configuration that is implicitly created by NB. This is unfortunate, because NB seems to create pretty advanced/complex configurations even there would not be need for such.
In WSF/PHP the security configuration of a web service (from the client viewpoint) can be defined by using WSPolicy class. An instance of this class may be given as a parameter to WSClient, which will then use the configuration when calling the web service. WSPolicy object can be instantiated by two methods: either by defining the settings as an array of values or by feeding in a separate policy XML file. The array method does not allow managing all of the supported settings and can only be used in very simple cases.
Because of the restrictions of the array method, it is necessary to use a separate policy XML file to describe the configuration when calling a secure web service created using NB. The policy XML file can be manually formed by studying the web service’s WSDL, which in fact, contains all the necessary information inside its policy elements. Because the policy elements can’t just simple be copied and pasted to a separate file, it is usually easier to take an existing policy file as a template and then modify it to fulfill the requirements of the service based on the WSDL.
After creating a simple PHP script and the necessary policy file in XML, I was able to call the service as expected. Here are the files:
Unfortunately, I didn’t get WSDL mode working. The problem seems to be that even the useWSA value is set to true on WSClient, addressing is not used in the WSDL mode. This prevents using WSDL mode with web services configured alike with NB 6.1′s SecureCalculatorApp.