PHP + WSDL + SOAP - how to display the result of a web service on the screen

I'm just starting to work in PHP and would like to get advice on how to get the webservice result to display in an array.

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

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

This is what I have, but nothing 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);
+3
source share
1 answer

This is basically the $ country variable.

If you look at the ConversionRate Web service, it will define FromCurrency and ToCurrency as needed.

  <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 need to update $ such a country:

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

That should work.

+9
source

Source: https://habr.com/ru/post/1698553/


All Articles