ez projects / ggwebservices / forum / general / processing xml response
You need to be logged in to post messages in the forums. New users may register here.
|
Member since: Posts: 1 |
Tuesday 26 July 2011 8:56:28 am Hi GG,
I'm evaluating ggwebservices and want to process a xml response of a REST request. It works very nice using your examples, which process json responses, but not with xml responses. In the webservice.log I can see, that correct xml results comes back, but I cannot process the results in templates. How to access the XML Content? Are there problems with namespaces or mixed namespaces? Here is an example using a public xml service: http://www.predic8.com/rest-demo.htm . My context: PHP 5.2.10, ggwebservice 0.9.1, SimpleXML 1.151, ezPublish 4.1.4 wsproviders.ini: [test] providerType=REST providerUri=http://www.thomas-bayer.com/sqlrest/CUSTOMER/ Template: {def $results = fetch('webservices', 'call', hash('server', 'test', 'method', '', 'parameters', hash()))} {$results} {$results|attribute(show)} Output: {$results} => Object(SimpleXMLElement) {$results|attribute(show)} => Attribute Type Value webservice.log: 2011-07-26 08:30:01 : Connecting to: http://www.thomas-bayer.com/sqlrest/CUSTOMER/ via REST 2011-07-26 08:30:01 : Sent: GET /sqlrest/CUSTOMER/ HTTP/1.0 Host: www.thomas-bayer.com Accept: application/json, text/xml; q=0.5 User-Agent: gg eZ REST client Accept-Encoding: gzip, deflate 2011-07-26 08:30:01 : Received: HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: application/xml Date: Tue, 26 Jul 2011 06:30:01 GMT Connection: close Content-Length: 39441 <?xml version='1.0' encoding='UTF-8'?><CUSTOMERList xmlns:xlink="http://www.w3.org/1999/xlink"> <CUSTOMER xlink:href="http://www.thomas-bayer.com/sqlre...999/">-9999</CUSTOMER> <CUSTOMER xlink:href="http://www.thomas-bayer.com/sqlre...-999/">-999</CUSTOMER> ....... <CUSTOMER xlink:href="http://www.thomas-bayer.com/sqlre...quot;>1999999999</CUSTOMER> </CUSTOMERList> Thanx for your help! Bernd |
|
|
Member since: Posts: 265 |
Tuesday 26 July 2011 10:28:27 am In fact this is a known missing feature of the extension - one that I have known for a long time and for which I still have not made up my mind as to what is the correct solution...
The problem is that the objects that you access in templates are either nested php arrays, or objects of a specific kind of php classes. But xml has a much richer content model than this: - attributes vs. elements - namespaces - entities This begs the question: how to map a rich xml object into a more simple eZ template object? I could make it simple and throw away every attribute and namespace, but I am sure that would not fit a lot of cases. Or I could make attributes and child elements in the xml all attributes of the template object... Any suggestions are welcome! Principal Consultant International Business |
|
|
Member since: Posts: 6 |
Tuesday 27 September 2011 6:58:52 pm Hi,
I have a same problem with WebServices using SOAP protocol. This is my case : 1- I define my server provider in file "wsproviders.ini.append.php" [AuthentificationServer] providerType=PhpSOAP providerUri= WSDL=http://mywebserver/authentication/server_wsdl.php 2- Then i access to my ws in template using this code : {def $return = fetch( 'webservices', 'call' , hash('server','Authentification','method', 'login', 'parameters', array(...))) } but i dont have any information, the return variable is empty When i investigate i find that in file extension/ggwebservices/classes/ggezwebservicesclient.php in a call method, the return is an stdclass : array 'result' => object(stdClass) public 'data' => ..... I think we must have a maping function to convert this object to an object that template can read. Tks Abdelkader RHOUATI |
|
|
Member since: Posts: 265 |
Sunday 30 October 2011 2:47:35 am @abdelkader: this should now be fixed. Can you try using the code from svn revision 405?
If you have a public server I can test, this is also fine Principal Consultant International Business |
|
|
Member since: Posts: 265 |
Sunday 30 October 2011 6:04:26 pm @bernd your problems should be fixed with svn rev. 406, which you are welcome to try (or just wait for release 0.10, which is coming soon... )
Principal Consultant International Business |
You need to be logged in to post messages in the forums. New users may register here.