PHP to Call Web Service


Use this php script to consume the webservice WS10R to
look up name and address of custNumber 9
(replace "[" with less than sign and "]" with greater than sign)

[html][body]

[?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.texas400.com/cgi-bin/WS10R");
// next line means don't echo data to screen
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '[custNumber]9[/custNumber]');

$result = curl_exec($ch);

$xml = simplexml_load_string($result);
print_r($xml);

curl_close($ch);
?]

[body][/html]

the browser will show:

SimpleXMLElement
Object ( [docID] => custLookup [custNumber] => 9
[custName] => IRA INDIGO
[custAdr] => 999 INNES BLVD
[custCity] => INDIANAPOLIS
[custState] => IN
[custZip] => 90009 )

 

Back to Main Page   |   Contact Info