5.5. Web Service instance

发布时间 :2023-12-28 23:00:03 UTC      

Any application can have Web Service components.

The creation of Web Service is independent of the type of programming language.

In this section, we will introduce you to using PHP’s SOAP extension to create Web Service.

SOAP has two modes of operation, NO-WSDL and WSDL.

  • NO-WSDL mode: use parameters to pass the information to be used.

  • WSDL mode: use the WSDL file name as a parameter and extract the informationneeded for the service from the WSDL.

5.5.1. An example: PHP Web Service

Before starting the instance, we need to determine whether PHP has the SOAP extension installed. Looking at phpinfo, the following message appears to indicate that the SOAP extension has been installed:

Image0

In this example, we will use PHP SOAP to create a simple Web Service.

Server side the Server.php file code is as follows:

<?php
// The SiteInfo class is used to process requests
Class SiteInfo
{
    /**
     *    Return website name
     *    @return string
     *
     */
    public function getName(){
        return "Rookie Tutorial";
    }

    public function getUrl(){
        return "www.runoob.com";
    }
}

// Create SoapServer object
$s = new SoapServer(null,array("location"=>"http://localhost/soap/Server.php","uri"=>"Server.php"));

// Export all functions in the SiteInfo class
$s->setClass("SiteInfo");
// Process a SOAP request, call necessary functions, and send back a response.
$s->handle();
?>

Client the Client.php file code is as follows:

<?php
try{
  // non-wsdl method call web service
  // create SoapClient object
  $soap = new SoapClient(null,array('location'=>"http://localhost/soap/Server.php",'uri'=>'Server.php'));
  // Call function
  $result1 = $soap->getName();
  $result2 = $soap->__soapCall("getUrl",array());
  echo $result1."<br/>";
  echo $result2;
} catch(SoapFault $e){
  echo $e->getMessage();
}catch(Exception $e){
  echo $e->getMessage();
}

At this point, we visit http://localhost/soap/Client.php and the output is as follows:

Image1

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.