PHP Phrasebook
| Actually, using a NuSOAP service is even easier than creating one. You just have to load the WSDL file and then get a so-called proxy class: That's a local class that behaves just as if the Web Service is a local class, too. So, you can call the Web Service's methods directly, and NuSOAP takes care of all the rest (including opening a connection to the remote server, assembling and parsing XML, and so on). To do this, the soapclient class (without the underscore character) must be instantiated, and then the getProxy() method creates the proxy class. The code implements this for the demo service from the previous example. Note the URL of the WSDL file: It's the Web Service's URL plus ?wsdl appended to the end; change the URL accordingly for your system. Consuming the Web Service with NuSOAP (wsdl-nusoap-client.php)
<?php require_once 'nusoap.php'; $soap = new soapclient('http://localhost/ wsdl-nusoap-server.php?wsdl', true); $proxy = $soap->getProxy(); $result = $proxy->add(47, 11); echo "47 + 11 = $result"; ?>
|
Категории