Mar21

My experiences with SOAP Web-service PHP vs .NET

Recently I have been developing web-services for integration of one of our flagship product to other POS software at Meditab Software. My official working platform is PHP and we have been developing web services for communication between our products to internal web applications in the past but it was like "We understand what we speak..!" as we have not been dealing with any external entity during these communications the input parameters used to be simple data-types and for output we understand what we give back using single simple data-type.

When I read requirement specification for the web service which I have developed recently I thought I could finish it in a day or two as I have been developing web-services recently. I went on and started and went into trouble with "complexType" declaration in WSDL. I was having C# example to work with provided by the company which was going to use my webservice. I tried that but the thing is when you use Microsoft ASP.NET platform to develop web services what developer needs to is just expose their method with [WebMethod] attribute and you are done! All hardwork and complex WSDL generation will be done by .NET framework. But when it comes to PHP you gotta deal with WSDL generation and make sure you do it perfectly or else your web-service won't work.

In PHP we have SOAP extension which really helps when we need to develop web services and that's what I have been using previously. But it doesn't help you/me for generating WSDL files and that part we have to bare with. I have searched out google for help but it was difficult to find perfect working example of Web service which takes in and out Complex Data types. Here Complex Data Type means user defined Classes and Arrays. When we work with ASP.NET we just declare it as WebMethod and everything goes smooth, we don't need to worry about WSDL generation and anything else. I tried to use the same WSDL generated from ASP.NET C# example but it didn't worked in my case and won't work for anyone. Here I mean we can get some idea about but direct copy + paste won't work. Because it has to be made in a way that SOAP extension understand that and generate RESPONSE and REQUEST XML in desired way. It took me considerable amount of time to got through the proper WSDL generation and I took almost 4 and 1/2 days to get that project done.

Here I would like to mention that PHP SOAP extension is not well documented and it requires quite a lot of hardwork when we need to deal with complicated Web Services. Although some WSDL generators are available (I am talking about some WSDL generator projects and Zend WSDL generator which comes with Zend Studio), they sometimes don't work perfectly for our requirement.

Here I would like to mention one more thing that eviware soapUI tool helped me for checking that whether my WSDL file is proper or not as ultimately it was supposed to be consumed on some other platform. I even tested it out on PowerBuilder 10.5 as it is actually our company's main product's development platform to make sure it's compatibility.

Even getting web service port on other platform took some considerable amount of time and XML and SOAP namespace nitty-gritty are difficult for newbie to get through. I am lucky I got a chance to develop this project.

I am planning to post proper example post explaining how to deal with PHP and SOAP web-services soon. I would like all readers to share their experiences with me on this blog for this subject.


3 Responses to “My experiences with SOAP Web-service PHP vs .NET”

You can leave a response, or trackback from your own site.

  1. Get a Gravatar!

    Vivek Despande

    Said this on May 7th, 2008 at 3:11pm:

    Currently i m facing the problem of php web service . Actually i m calling php web service in my asp.net application . i am calling one API which returns array of class but when i am calling from it dotnet application it returns null value.

    Can you please help me for that.

    Thanks

    Vivek

  2. Get a Gravatar!

    Vivek Despande

    Said this on May 7th, 2008 at 3:13pm:

    Hello All,

    I am calling third party php webservice in my asp.net application.

    LocalhostXYZ srvLogin = new Localhost.XYZ();

    Localhost.LogonResponseArray arryObj = new LogonResponseArray();

    arryObj = srvLogin.logon(”abc”, “pqr”, “xyz”);

    Where logon() is API from Php Web service.

    Return type of logon() method is LogonResponseArray class which is of array type.

    I am facing one problem that arryObj returns null value.

    So can any one tell me how can i get proper value.

    Thanks

    Vivek Deshpande

  3. Get a Gravatar!

    Dharmavirsinh Jhala

    Said this on May 7th, 2008 at 11:45pm:

    Hi Vivek,

    Do you have php code for that service or could you just publish WSDL for that?
    As the reason being it is possible that SOAP version conflict or xml specification issue with that.

    If that third party extension is using PHP SOAP extension then lot of things depends on WSDL specification, as PHP’s SOAP extension (SoapServer) will read the WSDL and parse response XML envelope in that manner.

    For that you can do at least one thing, try creating PHP SoapClient and test it with PHP Client and see do you get proper result or not?

    Here is the possible sample code for creating Test Client in PHP for your web service.

    $LoginClient = new SoapClient(”http://localhost/services/login.wsdl”, array(”trace”=>1));

    // See the functions webservice is exposing
    echo ‘<pre>’;
    print_r($LoginClient->__getFunctions());

    // Call the function
    try
    {
    $arrResponse = $LoginClient->Logon(”abc”, “pqr”, “xyz”);
    }
    catch(SoapFault $exception)
    {
    echo $exception;
    }

    // Print response on screen
    print_r($arrResponse);

    // See what kind of xml request SoapClient is sending
    $LoginClient->__getLastRequest();

    // Check with what kind of xml response SoapServer is responding back
    $LoginClient->getLastResponse();

    Let’s see whether it helped or not? If you can provide wsdl then it would be easier to help.


Leave a Reply

Recent Posts

Popular Categories

About

blogs@DiGiTSS is owned by Dharmavirsinh Jhala and Gaurav Gajjar.

Dharmavirsinh is working as PHP Team Lead at Meditab Software Inc, and now he is into PHP world for more than 2 years. He is having experience of building complex Web Applications (CRM, ERP), Web services and complicated real world custom applications and much more. He has been handling deployment of projects on either Client's server or company's server.

Gaurav Gajjar is working for Conchango as Technical Consultant from QuickstartGlobal and has been providing solutions with Microsoft.NET technology for nearly 4 years. He is having reputation of finishing his projects on or before time most of the time. He is right now working with AGILE development methodology to deliver solutions.

Both are known to achieve what they want and they are good friends, they know each other since last 10 years. They can provide solution for any technical problem, even though if they are facing it for the first time. You can put them in worst condition and they will get out of it, ready to take on any challenge.

Now days I have been hearing term "Rock star" for programmers, I believe they have it all what it takes to be a Rock star.