B
B
bkistav2014-11-26 10:54:36
PHP
bkistav, 2014-11-26 10:54:36

How to display the results of a WSDL query in html?

Hello.
Wrote a simple client to work with a WSDL service.

<?php
$client = new SoapClient("http://www.webservicex.net/geoipservice.asmx?WSDL");
$result = $client->GetGeoIPContext();
var_dump($result);

print $result; // Issue: Catchable fatal error: Object of class stdClass could not be converted to string
?>

var_dump results :
object(stdClass)[2]
  public 'GetGeoIPContextResult' => 
    object(stdClass)[3]
      public 'ReturnCode' => int 1
      public 'IP' => string '62.122.245.38' (length=13)
      public 'ReturnCodeDetails' => string 'Success' (length=7)
      public 'CountryName' => string 'Russian Federation' (length=18)
      public 'CountryCode' => string 'RUS' (length=3)

How to output from $result IP, CountryName and CountryCode to html as a table?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Benkovsky, 2014-11-26
@bkistav

Well, what is not clear? Your interpreter won't let you convert an object to a string because it doesn't know how to do it. You also know where the fields you need are located:

echo $result->GetGeoIPContextResult->IP;
echo $result->GetGeoIPContextResult->ReturnCode;
echo $result->GetGeoIPContextResult->CountryName;
echo $result->GetGeoIPContextResult->CountryCode;

read the basics of the PHP language, working with objects

B
bkistav, 2014-11-26
@bkistav

Thank you! =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question