Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by David on Jul 25, 2008 16:34
open dhtmlx forum
php ws client-java web service-dhtmlx datagrid

I'm trying to get data from a java webservice and display the information on the dhtmlx grid.

Here is my configuration :
- php client using nusoap
- java web service using xfire
- dhtmlx datagrid parse using json (json_encode() is used to transform the xml to json format)

client.php...
<?php
require_once('../lib/nusoap.php');
$client = new SoapClient('http://localhost:7272/services/UserService?wsdl', array('encoding'=>'UTF-8'));
$param = array('in0' => 'JJ');
$result = $client->call('findLikeInitials', $param);

echo '<p>' .json_encode($result["out"]);
?>

The output is the following...

{"User":[{"firstName":"David","id":"555","initials":"JJ1","lastName":"Jones"},{"firstName":"Mark","id":"654","initials":"JJ2","lastName":"McGwire"},{"firstName":"Greg","id":"8741","initials":"JJ3","lastName":"Maddux"},{"firstName":"Don","id":"1112","initials":"JJ4","lastName":"Mattingly"},{"firstName":"David","id":"4444","initials":"JJ5","lastName":"Ortiz"}]}

Is dhtmlx grid flexible to use the above format w/ configuration parameters ? (similiar to the xmlB option that allows you to specify the xml tag name). note: i would like to avoid writing php code to transform the ws result to a json format that dhtmlx understands.

Also, I'm open to alternative approaches... but I must call a java web service written w/ xfire directly from the client (i.e. using javascript, php, etc).

Thx in advance.
Answer posted by Support on Jul 28, 2008 03:30
The structure of used JSON can't be seriously changed, so there is no way to load the data in such format.
You have two possibilities
a) Create custom data parser ( which is not such complex task ), for your custom format
    http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Custom_loading_types.html#grid_art_custloadtypes
b) use XML instead of JSON, as far as I can see, original XML received from webservice must be very similar to xmlB format, which supported by grid
    http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Loading_data_in_grid.html#grid_art_loadingdata