Thursday, December 30, 2010

How to statically serve a wsdl with WSF/PHP.

WSF/PHP has two modes of operations. When using wsdl mode, you will always start with a wsdl and hence, that wsdl will be served for ?wsdl request. On the other hand, you can write a service with annotations and the corresponding wsdl will be generated for you. However, when using the xml-in-out mode with WSMessage object as the input and output parameter for the operation, its better to be able to serve a wsdl that is saved in the server since auto generated wsdl’s schema might not match the operation accepted xml.

Getting this done is quite simple. all you need to do is to set the option “omitProcesswsdl” in WSService operations array to true. 

$opParams = array("testFunction"=>"WSMESSAGE");

$service = new WSService(array(  "wsdl"=>"mystaticwsdl.wsdl",
        "omitProcesswsdl"=>TRUE,
        "opParams"=>$opParams,
        "operations" => $operations,
        "actions"=>$actions );

By specifying omitProcesswsdl, you can prevent WSF/PHP from trying to process the operation as a WSDL Mode operation. Also note that you would need to set your function as of type WSMESSAGE by using opParams. This is a work about which is not required for current svn trunk.
 

Tuesday, December 14, 2010

Running Objective C code on Windows 7

If you are on Windows and want to run object c code, there are few Objective C  compilers available for windows. One such implementation of Objective C spec is  GNUstep project which has implementations for a number of operating systems including windows.

Installing it is straightforward. Download and run the installers in the specified order. Once its complete,  you will get a GNUstep option in the start menu.

start 

Shell can be used to compile and run programs including Objective C programs. This shell has most of the unix programming utilities including gcc, g++ , make and gdb.

In order to build and run a sample program, easiest way is to use a makefile. For GUNstep, the makefile should be named GNUmakefile. If the makefile uses any other name, it should be specified in the make command.

Monday, December 13, 2010

How to fix VMWare server 2.0 VM No Internet Access issue on Windows 7

If you are on windows 7 and using VMWare 2.0. server, your virtual machines will have a problem of accessing the internet. 

nonetwork

However, there is a work around to get network access with the VM using the windows Internet Connection Sharing option. First open up the WMWare Virtual network editor vmnetcfg.exe located at C:\Program Files (x86)\VMware\VMware Server. 

image 

On the “Host Virtual network Mapping” tab , for VMNet1, click the > button and select subnet option. Put an Ip address other then 192.168.137.0 and click OK.  For VMnet8 adaptor click > and set the subnet ip to 192.168.137.0 for the subnet option and on the default gateway option, set 192.168.137.1 and click OK. This is the IP address Windows 7 assign when using Internet connection sharing option.

Open the ‘Network and Sharing Center’ from control panel and click ‘Change Adaptor Settings’ Open the properties for your active Internet connection, go to sharing tab and click the check box with option “allow other network users to connect through this computer’s internet connection” and for the Home networking connection , Select to connect though VMnet8.

 image

Windows will tell that it will assign IP 192.168.137.1.

If your VM machine does not have a fixed IP configured , it should be able to access internet without issue now. In case, it has a fixed IP configured, VM IP4 gateway and DNS1 should be changed to 192.168.137.1

Wednesday, October 27, 2010

Google Transliteration IME

Google transliteration input method supports many languages including Sinhalese. One great feature is the availability of the ‘zero width joiner’ and ‘zero width non joiner’ support with makes is so easy to type the combined characters which are otherwise hard to get right.  It includes this typing keypad as well.

image

In addition, the transliteration web page is also available.

image

With the IME installed, all you need to do is to select the input method and you are off typing in Sinhalese. සිංහළෙන් බ්ලොග් ලියමු දැන්.

Download transliterating IME from http://www.google.com/ime/transliteration/

image

Sunday, August 29, 2010

Memory Lane

WSO2 is celebrating its fifth anniversary. I have been at wso2 for exactly 5 years today.So I decided to put together some special moments at WSO2. There were many and these are the photos I could find.

OLYMPUS DIGITAL CAMERA

This was the first WSO2 day out. This was way back in 2005 and place is blue waters. From left to right, Chamil, Sahan, Ruchith, Chinthaka, Saminda, Sanka, Deepal, Buddhika, Chamikara,Dr Sanjiva, Samisa and me.IMG_0019

This was the first major WSO2 product release. WSO2 WSAS was called Tungsten in those days. With ‘w’  representing Tungsten in the periodic table and w being the starting letter of the company name, it was decided to name WSO2’s first product as Tungsten. Sad that those metallic product names had to go away.

Picture 045

Samisa was the first wso2 employee to get married while at WSO2. It was Axis2/C early days and we were on a tight release schedule on those days. The C team had a call with Samisa even on his wedding holidays!.

03-sigiriya-by-chamil-069

04-safari-by-samisa-051

This was the first official WSO2 trip. It was to habarana lodge. The food there was awesome and the guys had put up a few kilos by the time we left. The top photo is taken at the entrance of Sigiriya. The second one was taken at Echo park. Deep and Me ended up going to this place three times.

IMG_0074

This is one of the group photos taken inside the old WSO2 office in merchant tower.  Everyone is dressed to go to a wedding as I remember.  From left to right, its Sandakith, Nandika, Azeez, Saminda, Asanka, Milinda, Ajith, Chinthaka, Deepal, Ruchith, Chamikara, Sanjaya, Sahan, Amila, Sanka, Samisa and Damitha. 

DSC_0184_small

WSO2 has grown and prospered over five years and this is how it looks in 2010.

Monday, July 5, 2010

WSO2 Web Services Framework for PHP 2.1.0 Released

I am pleased to announce the release of v2.1.0 of  wso2 wsf/php. This release comes after quite some time since the 2.0.0 release was back in late 2008. Since then a lot of changes have token place in the underlying code base of WSF/PHP. The WS-Security handling has been improved and updated and that functionality is now available with this release of WSF/PHP. In addition to that, this release is built and tested for PHP 5.3. Many users have been querying about a PHP 5.3 compatible release for a while and with this release, all the issues users had with installing and running on php 5.3 will be solved. Libxml2 dependency has been removed from the default build and it uses build-in Guththila xml parser for xml handling which should also improve the performance.

You can download the release from http://wso2.org/downloads/wsf/php.

You can find the complete release note here.

https://svn.wso2.org/repos/wso2/branches/wsf/php/2.1.0/NEWS

Enjoy WSO2 WSF/PHP 2.1.0.

Friday, May 21, 2010

How to configure https for Apache2.2 and consume PHP web services over https

Step 1.

Create a Certificate Authority, CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt

Now we have a certificate authority certificate to sign the certificate for the server.

Step 2.

Generate a key for the server.

openssl genrsa -des3 -out server.key 4096

Generate a certificate signing request

openssl req -new -key server.key -out server.csr

Optional step : remove the passphrase from the key

Rename server.key to server.key.bac.

openssl rsa -in server.key.bac -out server.key

Step3.

Sign the generated key with certificate authority

openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt

Now we have the necessary keys and certificates to configure Apache2.2 server to enable https

Step4.

copy the generated keys, certificates to a directory named keys under the conf directory.

Uncomment ssl module and ssl configuration file in httpd.conf.

LoadModule ssl_module modules/mod_ssl.so

Include conf/extra/httpd-ssl.conf

Step 5.

configure https in httpd-ssl.conf file located in conf/extra directory. Use the default settings and specify the following Files to match your local settings.

SLCertificateFile "F:/Apache2.2/conf/keys/server.crt"

SSLCertificateKeyFile "F:/Apache2.2/conf/keys/server.key"

SSLCACertificateFile "F:/Apache2.2/conf/keys/ca.crt"

#SSLVerifyClient require

SSLVerifyDepth 1

SSLVerifyClient and SSLVerifyDepth options would only be required, if you want the client to authenticate to the server using a certificate and a passphrase.

Now you have successfully configured https for your server.

When connecting to the server, you can obtain the servers certificate by using openssl.

openssl s_client –connect localhost:443 > scert.pem

Now open the scert.pem and remove the unnecessary. Only the content within the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- needed for the certificate. You certificate would look like

-----BEGIN CERTIFICATE-----

-----END CRETIFICATE-----

Step 6.

Now we can connect to a service deployed in Apache server using https and consume it.

$client = new WSClient(array(“to”=>”https://localhost/webservices/service1.php”,

                                                “CACert”=>”cert.pem”));

$response = $client->request($input);

Much more detailed discussion on implementing https alone with Axis2/C is available here.

Sunday, March 14, 2010

WSF/C++ Performance Comparison

We carried out a simple performance comparison between WSF/C++ , WSF/C against a set of other web services products. The results are published here.

Wednesday, March 10, 2010

WSO2 Carbon Based Admin Console for Axis2/C WSF/C and WSF/C++

http://wso2.org/projects/wsf/cppWith the availability of WSO2 WSF Admin, now users can manage their C and C++ Web Services Deployed in Axis2/C, WSF/C or WSF/C++ using the GUI interface of Carbon. At present, WSF Admin is at first milestone and supports following set of features.

Service Listing and Module Listing

Security Configuration

Policy Editing

Service Statistics

Following are some of the screen shots of New WSF Admin Console with WSF/C++.

Service Listing servicelisting

Engage Statistics Module to a service using the admin console and view the service usage statistics.

engage

stats

Configure Security

security

View and Edit Service Policies

policies

There are lots of other functionality in-addition to the once I have shown above.  WSF Admin is a set set of web services and modules implemented using WSO2 Web Services Framework, plus a Customized Carbon Instance. The Admin Console works by using web services interactions to the WSF/C Back End where the C Admin Services deployed. WSF Admin is also a demonstration of not only the interoperability of WSO2 products ( Between java based Carbon Platform and C/C++ based WSF Products ) but also the flexibility of WSO2 Carbon Platform. 

WSF Admin milestone 1 release does not have the persistence and hence the configuration changes you make will not be preserved once you shutdown your server. The next release of WSF Admin will be having the persistence capability.

Wednesday, January 27, 2010

Making the Skeleton Dance

This is a very interesting marketing strategy.  A guy walks into an into an interview and  highlights his negatives.

As I look over my copy of Thompson's application, I mentally reduce his chances from minuscule to nonexistent. I glance at my watch. I've got an early flight. I wonder how long it will take my compatriots to blow poor Thompson off.
"So why should we hire you, Mr. Thompson?" the area manager asks, starting with the question she usually finishes with.
Thompson smiles.
"I'm 53 years old," he says without hesitation. "I'm not pretty. I've been unemployed for almost five months—ever since my last company went belly-up. I've got no experience in your industry. If you take a look at my application you'll see that there's a checkmark next to the yes on that question about whether or not I've ever been convicted of a felony. I've applied for any number of other jobs and no one else will hire me." He looks at us each in turn while he's slowly ticking off these points on his fingers, as confidently as if he were explaining his Harvard MBA, his Olympic gold medals and his seven years as CEO of General Motors. "So let me tell you why I'm the best possible candidate you're ever going to find for this position."
And that's exactly what he proceeds to do—demonstrating the poise and assurance and experience he'd gained in those 53 years.
"If you hire me, I can't afford not to succeed!" he tells us with passion and conviction. "I don't have the option of being able to move on to greener pastures—or even brown pastures—when the job gets too grueling. I'm 100 percent committed. As locked into this position as I was locked into that jail cell 35 years ago. And if you'll notice that's where I earned the most of the credits for my college degree. I never wanted a Master's, so I've made sure I've never had to go back. But what I learned in that place—the formal and the informal training—has a lot to do with why I've been so successful at every job I've had since then."

Read the full article here.

http://www.evancarmichael.com/Sales/372/Making-the-Skeleton-Dance-Bragging-about-the-Negatives.html

Monday, January 18, 2010

How to write a custom message receiver for WSF/CPP

When you have to go beyond the supported interface of a ServiceSkeleton when implementing a service, you can use a custom message receiver to achieve that functionality.  For example, recently we encountered such scenario where the unparsed soap enveloped body has to be accessed for some custom logic. But when implementing a service using ServiceSkeleton interface, you would always ended up getting the first child of the soap body as an argument.

In that kind of a situation, the best option would be to implement a custom message receiver. WSF/CPP now provides a very convenient API for implementing a message receiver. 

For implementing a custom message receiver, WSF/CPP provides a class named MessageReceiver. What a user has to do is to extend from this and implement the abstract method invokeBusinessLogicSync which will receive inflow message context and outflow message context as arguments. Then you have the full control over the processing of the message received by the message receiver.

Next add the macro WSF_MESSAGE_RECEIVER_INIT and pass the message receiver class name as the argument.

Next compile the written code as a shared library and place it in <WSFCPP_REPO>\lib directory. When implementing a service which would be invoked using this custom message receiver, set the name of the shared library as the “messageReceiver” parameter for each operation. For example, if the shared library name is “CustomMsgRecv

<operation name=”Op1”><messageReceiver class=”CustomMsgRecv”/></operation>

Here is the example message receiver code.

/* CustomMsgRecv.h */

#include <MessageReceiver.h>

class CustomMsgRecv : public wso2wsf::MessageReceiver
{
public:
WSF_EXTERN bool WSF_CALL
invokeBusinessLogicSync(wso2wsf::MessageContext *inMsgCtx,
wso2wsf::MessageContext* outMsgCtx);
CustomMsgRecv(void);
~CustomMsgRecv(void);
};


/** CustomMsgRecv.cpp */



#include "CustomMsgRecv.h"
#include <MessageReceiver.h>

using namespace wso2wsf;

WSF_MESSAGE_RECEIVER_INIT(CustomMsgRecv)

CustomMsgRecv::CustomMsgRecv(void)
{
}

CustomMsgRecv::~CustomMsgRecv(void)
{
}

WSF_EXTERN bool WSF_CALL
CustomMsgRecv::invokeBusinessLogicSync(wso2wsf::MessageContext *inMsgCtx,
wso2wsf::MessageContext *outMsgCtx)
{
/** Add Your Logic Here */
}