limessl Posted February 13, 2010 Share Posted February 13, 2010 I'm having trouble with an API. I usually send the data to the API using $client = new soapclient_gt($order_url, 'true'); $result = $client->call('QuickOrder',$params); And from that I can simply use variables such as $result->field1 in order to read the response. However from the code I've been given there appears to be a bug in nusoap which means the particular example I'm working on simply fails (I have absolutely no idea what the bug is, but I've tried to call the API using the above format and it does indeed fail to even send the request properly). So, in this example I'm having to build the whole XML file as a variable and send it using $client->send($xml); The problem is that I have no idea how to extract the array from $client->response. If I use print_r($client->response) and then look at the page source, it shows me this :- HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Sat, 13 Feb 2010 10:09:57 GMT Transfer-Encoding: chunked Content-Type: text/xml; charset=utf-8 SOAPAction: "" X-Powered-By: Servlet/2.5 JSP/2.1 <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><m:QuickOrderResponse xmlns:m="http://api.geotrust.com/webtrust/order"><m:QuickOrderResult><m:OrderResponseHeader><m:PartnerOrderID>10798969383858392</m:PartnerOrderID><m:SuccessCode>0</m:SuccessCode><m:Timestamp>2010-02-13T10:10:00.189+00:00</m:Timestamp></m:OrderResponseHeader><m:GeoTrustOrderID>106776</m:GeoTrustOrderID></m:QuickOrderResult></m:QuickOrderResponse></env:Body></env:Envelope> I need to create a variable called $success which looks at the value of SuccessCode, in the above example this would be 0. I have run out of google searches so I'm going to pass it onto the experts Quote Link to comment https://forums.phpfreaks.com/topic/191952-extracting-an-array-from-an-xml-response/ Share on other sites More sharing options...
salathe Posted February 13, 2010 Share Posted February 13, 2010 Where did you get the soapclient_gt class from? Quote Link to comment https://forums.phpfreaks.com/topic/191952-extracting-an-array-from-an-xml-response/#findComment-1011743 Share on other sites More sharing options...
limessl Posted February 13, 2010 Author Share Posted February 13, 2010 It's in nusoap.php - the header is :- $Id: nusoap.php,v 1.69 2004/02/23 19:42:19 snichol Exp $ NuSOAP - Web Services Toolkit for PHP Copyright © 2002 NuSphere Corporation Quote Link to comment https://forums.phpfreaks.com/topic/191952-extracting-an-array-from-an-xml-response/#findComment-1011749 Share on other sites More sharing options...
salathe Posted February 13, 2010 Share Posted February 13, 2010 Is there any reason why you're using a really old version of NuSOAP? Quote Link to comment https://forums.phpfreaks.com/topic/191952-extracting-an-array-from-an-xml-response/#findComment-1011751 Share on other sites More sharing options...
limessl Posted February 13, 2010 Author Share Posted February 13, 2010 It was the one I was sent with the rest of the package. I've just clicked that I actually have a much newer version already installed on my server - I'll see if that solves the problem. Quote Link to comment https://forums.phpfreaks.com/topic/191952-extracting-an-array-from-an-xml-response/#findComment-1011752 Share on other sites More sharing options...
limessl Posted February 13, 2010 Author Share Posted February 13, 2010 OK I now have a new version of nusoap, sadly all the functions and syntax is different and the furthest I can get is an error saying :- Array ( [faultcode] => env:Server [faultstring] => Failed to invoke end component webservice.Order (POJO), operation=ValidateOrderParameters -> Failed to invoke method [detail] => Array ( [string] => java.lang.NullPointerException ) ) I'm afraid this is all far too complex for me Quote Link to comment https://forums.phpfreaks.com/topic/191952-extracting-an-array-from-an-xml-response/#findComment-1011791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.