XML Attributes in your payload
Friday, June 27, 2008
<xs:complexType name=\"myType\">
<xs:sequence>
<xs:element name=\"demo1\" type=\"xs:string\"/>
<xs:element name=\"demo2\" type=\"xs:string\"/>
</xs:sequence>
<xs:attribute name=\"demo3\" type=\"tns:derivedType\"/>
</xs:complexType>
PHP webservices demo site have samples WSDLs that defines attributes http://labs.wso2.org/wsf/php/solutions/wsdl_mode/AttributeService.php?wsdl. And you can test a sample service setting your clients endpoint to http://labs.wso2.org/wsf/php/solutions/wsdl_mode/AttributeService.php. Write your client with the help of the generated code for the WSDL. You can try it online from Here. And make sure you have installed WSF/PHP to do all of these.
Testing https requests with WSClient
Tuesday, June 24, 2008
$client = new WSClient(array("wsdl"=>"sample_wsdl_11.wsdl",
"to" => "https://6ec2.dyndns.org/samples/wsdl_mode/wsdl_11_service.php",
"CACert" => "server.crt"
));
Use the approach mentioned in this blog post to generate the above server.crt certifcate.
Then run the sample in the command prompt or shell
php wsdl_11_client.php and test whether the response comes as expected. if not you have to check the wsf/php instatllatioin steps again.
New Features in the PHP Data Services Library
Thursday, June 19, 2008
Here are the new features in the latest PHP Data Service Library,
1. Multiple data base engine support (with php PDO extension)
2. Nested Query support
3. New Array based API, documented at
http://wso2.org/wiki/display/wsfphp/API+for+Data+Services+Revised
4. dbs2php converter, convert WSAS Java data services configuration XMLs to PHP code.
5. WSDL Generation support - works only with the latest WSF/PHP SVN.
You can check the Demos powered by the new library from here. You can see the newly added demo4 that demonstrates the Nested Queries.
And Online dbs2php tool is available from here. Anyway in the demo site the ?wsdl will not work, since it is hosted with wsf/php 1.3.2. (If you want ?wsdl for data services, please use the latest WSF/PHP svn)
Choose among multiple services, multiple ports
For an example if you take wsdl1.1 with multiple services and ports like this,
<wsdl:service name=\"Adder1\">
<wsdl:port name=\"SOAP11port_http\" binding=\"ns0:AdderSOAP11Binding\">
<soap:address location=\"http://localhost:8080/axis2/services/Adder1\"/>
</wsdl:port>
<wsdl:port name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\">
<soap12:address location=\"http://localhost:8080/axis2/services/Adder1\"/>
</wsdl:port>
<wsdl:service/>
<wsdl:service name=\"Adder2\">
<wsdl:port name=\"SOAP11port_http\" binding=\"ns0:AdderSOAP11Binding\">
<soap:address location=\"http://localhost:8080/axis2/services/Adder2\"/>
</wsdl:port>
<wsdl:port name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\">
<soap12:address location=\"http://localhost:8080/axis2/services/Adder2\"/>
</wsdl:port>
<wsdl:service/>
You can select the Adder2 service with SOAP12port_http with the following optional arguments to the getProxy method.
$client = new WSClient(array(\"wsdl\" => \"your_wsdl\"));
$proxy = $client->getProxy(\"Adder2\", \"SOAP12Port_http\");
This can be represented in wsdl2 as following,
<service name=\"Adder1\" interface=\"ns0:AdderPortType\">
<endpoint name=\"SOAP11port_http\" binding=\"ns0:SOAP11Binding\" address=\"http://localhost:8080/axis2/services/Adder1\"/>
<endpoint name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\" address=\"http://localhost:8080/axis2/services/Adder1\"/>
</service>
<service name=\"Adder2\" interface=\"ns0:AdderPortType\">
<endpoint name=\"SOAP11port_http\" binding=\"ns0:SOAP11Binding\" address=\"http://localhost:8080/axis2/services/Adder2\"/>
<endpoint name=\"SOAP12port_http\" binding=\"ns0:AdderSOAP12Binding\" address=\"http://localhost:8080/axis2/services/Adder2\"/>
</service>
Note that here portName you provided is considered as the endpoint name under the selected service.
When you don't provide either serviceName and the portName, wsf/php will pick the first serviceName and portName listed in the wsdl.
Although multiple services in the same wsdl is very rare, multiple ports /endpoints in the same service is very common. Specially when you support multiple versions of SOAP, addressing, or even completely different policies for the interface you will surely be having multiple ports.
WSF/PHP Code generated for Some famous Web Services
Sunday, June 15, 2008
Java DataServices to PHP Code Generator
Saturday, June 14, 2008
But how if someone already have Java configuration XML or say he may prefer writing configuration in XMLs. Well we have a solution for them too.
With the next PHP Data Service library, there will be a code generation tool which give you the WSF/PHP DataServices code from the Java DataService configuration file.
One reason PHP is so much popular is its easiness in working with databases. And I believe our DataService library will fill some of the blank spaces that were there in the PHP space, specially in connecting PHP database developers with the emerging SOA world.
Verify your WSF/PHP installation
Friday, June 13, 2008
1. run the following command in command line ( make sure php is in your 'PATH' environment variable)
php -m
This will lists the php modules. There you should see wsf and xsl. if either or both of this missing, check xsl.dll(or xsl.so in linux) and wsf.dll(or wsf.so in linux) in the extension directory and the php.ini extension entries.
2. Run the following command
php -i
This will list out the configuration details of php installation. Just check the entries like include_path, to check whether you have set scripts directory under it. (In linux you can check this more easily with
php -i | grep include_path
command.
The above tests can be done using the phpinfo function as well. For that you will create a file (say phpinfo.php) in the apache document root with the following script.
phpinfo();
?>
and you call it from the browser (say http://localhost/phpinfo.php). and you have all the details like installed extensions (check xsl and wsf) and their configurations + include_path entries. You can verify your installation with this.
Anyway there may be chances that even though you have all these right but still samples doesn't work. Most probable reason for that result can be that you are upgrading from old wsf/php library and you already have some of old libraries in you PATH. so make sure you delete or move the old libraries to complete seperate place before you install new libraries.
And if still it didn't work just feel free to ask it in the wsf/php forum or the mailing list. Surely there should be a workaround.
PHP Data Service API revised
Thursday, June 12, 2008
The next version of this library includes providing multiple database support ( in fact using the PDO extension), nested query support, WSDL generation and ability to define elements, attriubutes and text of soap payload from database data and many more. But this will not break the current simple API.
For this we came with a revised API for the DS library. I did a rough documentation (hopefully this will be improved with the time) on this at here. And this is an attempt to make it more closer to the Java Data Service API and the implementation. The ultimate goal is to allow the Data Services to move from Java to PHP and and vice versa in no time. We will let you know, when it is ready and I believe it won't be that far.
PHP Web Services Interoperability with Microsoft .NET
Wednesday, June 11, 2008
In the Microsoft TechED 2008 keynote, there was a demonstration on WSF/PHP and .NET 3.5 interoperability using the stock trader application. Watch the video.
I was responsible for setting up the PHP stuff for the demo. Red my testimony on how easy it was to get the stuff working.
Also, you can read more information form the presenter himself, Jonathan.
WSF/PHP on TechEd IT 2008
Tuesday, June 10, 2008
WSDL Generation with arrays
So we came up with a mechanism to describe the service operation and operation parameters using arrays in addition to the annotation API already shipping with WSF/PHP.
You can visit here, for complete demonstration on the array based annotation API which is to going to be part of the WSF/PHP next release.
Http Basic Authentication in WSF/PHP
Monday, June 9, 2008
Here is how you are going to do it with WSF/PHP. I will take simple echo sample to demonstrate this,
server side:
You have to configure apache to do the authentication, so the php and wsf/php applications which are running behind the apache server also get authenticated. The following guide will help you to do the configuration very easily,
http://apache.active-venture.com/auth-basic.html
Your server side code is same as the code for a regular service
<?php
function echoFunction($inMessage) {
$outMessage = new WSMessage($inMessage->str);
return $outMessage;
}
$operations = array("echoString" => "echoFunction");
$service = new WSService(array("operations" => $operations));
$service->reply($requestPayloadString);
?>
client side:
<?
$requestPayloadString = <<<XML
<ns1:echoString xmlns:ns1="http://php.axis2.org/samples"><text>Hello World!</text></ns1:echoString>
XML;
try {
$client = new WSClient(array( "to" => "http://localhost/samples/echo_service.php",
"httpAuthUsername" => "xxx",
"httpAuthPassword" => "x@x",
"httpAuthType" => "Basic",
));
$responseMessage = $client->request( $requestPayloadString );
printf("Response = %s
", htmlspecialchars($responseMessage->str));
} catch (Exception $e) {
if ($e instanceof WSFault) {
printf("Soap Fault: %s\n", $e->Reason);
} else {
printf("Message = %s\n",$e->getMessage());
}
}
?>
You will fill the fields specific to http authentication. And here you have web service client and service which uses http basic authentication.
Web Services Interoperability Demo with WSO2 Stock Trader Implementation
The stock trader sample application implemented by both IBM and Microsoft, is now also available in PHP and Java with WSO2 SOA Stacks.
The PHP implementation is based on WSO2 WSF/PHP and the Java implementation is based on WSO2 WSAS.
The application has three layers, presentation, middle tier and the back end. Presentation tier talks to the middle business services layer and the business service layer talks to the back end order processing layer. PHP implementation has all the three layers implemented. Java implementation has the order processing layer implemented.
Both the PHP and Java layers can work with each other, as well as with the .NET implementations of the three tiers. You can mix and match tiers, swap them with each other, to get the same SOA behavior.
As an example, as shown in the above diagram, PHP presentation tier can talk to the .NET business service layer and the .NET business service layer can talk to the Java order processing layer. And it can use advanced WS-* specs such as WS-Security, between tiers and you can still get the tiers achieve seamless interoperability.
WSDL Generation with and without $classmap option
Sunday, June 8, 2008
When you provide classmap option, your service function declration should be such that it input the request object and output the response object.
When you don't provide classmap option, you will have a service function declration with set of input fields as input parameters. (Note that in both cases the response can be either an array or response, only the request parameter set is different from each other in two cases)
You can see how the WSDL is genererting for both above cases, which will also demonstrate the different between the service fuction declarations.
1. When the $classmap is provided, http://labs.wso2.org/wsf/php/php2wsdltool.php?example=Example3
The function declration is
/**
* echoValue function
* @param object Foo $echoString echoString description
* @return object FooResponse $echoStringResponse
*/
function echoValue($echoString){
}
2. When the $classmap is not provided, http://labs.wso2.org/wsf/php/php2wsdltool.php?example=Example4
The function declration is
/**
* echoValue function
* @param array of object Foo $param1 param1 description
* @param string $param2
* @return array of object Boo $ret_value
*/
function echoValue($param1, $param2){
}
You can find more details at here, http://wso2.org/project/wsf/php/1.3.2/docs/wsdl_generation_api.html
Comprehensive PHP REST Support on the way
The next release of WSO2 WSF/PHP would have PUT and DELETE supported, along with GET and POST, and also, the user will have the luxury of configuring the URL mapping for a given operation.
Nandika has already implemented this and is in the svn trunk of WSF/PHP. Hopefully, we will be able to provide a complete sample on how to use the API, before we do release this feature.
Currently, the next release is planned for the end of July.
WSF/PHP Against different Schema Constructs
Saturday, June 7, 2008
You can find test cases for clients in here, https://wso2.org/repos/wso2/trunk/wsf/php/src/tests/samples/wsdl_mode and for service in here, https://wso2.org/repos/wso2/trunk/wsf/php/src/tests/samples/services/wsdl_mode
These test cases have a description about what scenarios it is testing and provide simple demonstrations how you should write programs for different schemas.
NEW WSClient option for the 1.3.0
Friday, June 6, 2008
Here are the WSClient options you will found in 1.3.* that was not there in earlier releases.
"httpAuthUsername" - Http basic/digest authentication was added in this release, here is where you give the username to authenticate
"httpAuthPassword" - Password for Http authentication
"httpAuthType" - What type of authentication is used. The possible values are "Basic" or "Digest"
"proxyAuthUsername" - Similar to http authentication, proxy authentication too added.
"proxyAuthPassword" - Password for Proxy authentication
"proxyAuthType" - Declare whether the authentication type used is "Basic" or "Digest"
"useMTOM" - This option was already there, but possible values were only TRUE/FALSE. With this release you can give another value to this option, i.e. "swa". You can enable SOAP with Attachement with setting "useMTOM" => "swa"
For more information look at the documentation http://wso2.org/project/wsf/php/1.3.2/docs/api.html
WSO2 Web Services Framework for PHP v1.3.2 Released
Thursday, June 5, 2008
Please try out the new release.
WSO2 Web Services Framework for PHP v1.3.2 Released
We are pleased to announce the release of WSO2 WSF/PHP 1.3.2.
WSO2 Web Services Framework for PHP (WSO2 WSF/PHP), is an open source,enterprise grade, PHP extension for providing and consuming Web Services in PHP. WSO2 WSF/PHP is a complete solution for building and deploying Web services and is the only PHP extension with the widest range of WS-* specification implementations. It's Key features include, secure services and clients with WS-Security support, binary attachments with MTOM, automatic WSDL generation (code first model),
WSDL mode for both services and clients (contract first model) and interoperability with .NET and J2EE.
Project home page: http://wso2.org/projects/wsf/php
Key Features
- 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
- 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
- Attachments with MTOM
- Binary optimized
- Non-optimized (Base64 binary)
- WS-Addressing
- Version 1.0
- Submission
- WS-Security
- UsernameToken and Timestamp
- Encryption
- Signing
- WS-SecurityPolicy based configuration
- WS-Reliable Messaging
- Single channel two way reliable messaging
- WSDL Generation for Server Side
- WSDL generation based on annotations and function signatures, and
serving on ?wsdl or ?wsdl2 requests
- WSDL generation based on annotations and function signatures, and
- 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
- REST Support
- Expose a single service script both as SOAP and REST service
- 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
- Consume some well known services such as Yahoo search and Flickr
- wsdl2php.php script. This script can generate PHP classes for services
and clients for a given WSDL to be used with WSDL Mode .
Major Changes Since Last Release
- Added HTTP Authentication support in WSDL mode
- Fixed memory corruption in wsdl mode
Reporting Problems
Issues can be reported using the public JIRA available at:
https://wso2.org/jira/browse/WSFPHP
Contact Us
Please subscribe to our user or developer mailing lists. For details on how to subscribe please visit: http://wso2.org/mail#wsfphp
We welcome your early feedback on this implementation.
Thank you for your interest in WSO2 WSF/PHP.