views:

2391

answers:

2

I'm just starting out in PHP and would like some advice as to how to get a webservice result to display in an array.

For example I would like to print the currency codes into an array from the following WSDL

$wsdl="http://www.webservicex.com/CurrencyConvertor.asmx?WSDL

This is what I have so far but nothing really happens:

$proxyhost="proxy.cpit.ac.nz";  
$proxyport = 8080;  

$wsdl="http://www.webservicex.com/CurrencyConvertor.asmx?WSDL";

$client = new SoapClient($wsdl,
  array('proxy_host' => "$proxyhost",'proxy_port' => 8080, 'trace' => 1));

$country=array();
$result = $client->ConversionRate($country);
print_r($result);
+6  A: 

Basically, it's your $country variable.

If you look at the ConversionRate Webservice, it defines FromCurrency and ToCurrency as required.

  <s:element name="ConversionRate"> 
    <s:complexType> 
      <s:sequence> 
        <s:element minOccurs="1" maxOccurs="1" name="FromCurrency" type="tns:Currency" /> 
        <s:element minOccurs="1" maxOccurs="1" name="ToCurrency" type="tns:Currency" /> 
      </s:sequence> 
    </s:complexType> 
  </s:element>

You'll need to update $country like so:

$country = array( "FromCurrency" => "AFA",
                  "ToCurrency" => "AUD");

That should work.

Nick Stinemates
A: 

I try to release a PHP WSDL BPEL engine, base on PHP CLI application server. Any help would be appreciated.

http://code.google.com/p/ezerphp/

Tan-Tan

Tan-Tan