Jump to content

php calling web service, please help!


sickmint79

Recommended Posts

i have soap mod enabled on php5.  i'm trying to get the spot price for gold in USD.  i found the service here:

http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=8

 

my code is as follows:

 

<?php


$client = new SoapClient(
"http://www.webservicex.net/LondonGoldFix.asmx?wsdl"
,array(
"proxy_host" => "proxy", 
"proxy_login" => "user",
  	"proxy_password" => "password",
  	"proxy_port" => 8080, 
"trace" => 1, "exceptions" => 0)
);

print "functions----<br>";
$functions = $client->__getFunctions();
print_r($functions);

print "<br><br>types----<br>";
$types = $client->__getTypes();
print_r($types);

$response = $client->GetLondonGoldAndSilverFix("Gold_AM_USD");
print "<br><br>response----<br>";
print_r($response);

print "<br><br><pre>\n";
  print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
  print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
  print "</pre>";
  
?>

 

you can remove the proxy server, user, pass and port to try the code yourself.  i have tried calling the method with no params, a 1, and the string above.  the response i get is 0s and failure.

 

[pre]response----

stdClass Object ( [GetLondonGoldAndSilverFixResult] => stdClass Object ( [Gold_AM_USD] => 0 [Gold_AM_STG] => 0 [Gold_AM_EUR] => 0 [Gold_PM_USD] => 0 [Gold_PM_STG] => 0 [Gold_PM_EUR] => 0 [silver_CENTS] => 0 [silver_PENCE] => 0 [silver_EUR] => 0 [status] => Failed ) ) [/pre]

 

this is my first time trying to do something like this.  please advise!  thanks.  :)

Link to comment
https://forums.phpfreaks.com/topic/175384-php-calling-web-service-please-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.