Hello!
I reference Internet example try to practice SOAP, but I get a problem
I didn't use NUSOAP, this is my code
server.php
<?phpinclude("webservice.class.php"); ini_set("soap.wsdl_cache_enabled", "0");$server = new SoapServer('webservice.wsdl', array('soap_version' => SOAP_1_2,'uri' => "abcd")); $server->setClass("webservice"); $server->handle();?>
webservice.class.php
<?php class webservice{ public function Add($a, $ { return $a + $b; } public function bbbbb() { return "Hello1234"; } }?>
webservice.wsdl
<?xml version="1.0" ?><definitions name="test" targetNamespace="urn:test" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/"><types xmlns="http://schemas.xmlsoap.org/wsdl/" /><portType name="testPort"> <operation name="Add"> <input message="tns:AddRequest" /> <output message="tns:AddResponse" /> </operation> <operation name="HelloWorld"> <input message="tns:HelloWorldRequest" /> <output message="tns:HelloWorldResponse" /> </operation></portType><binding name="testBinding" type="tns:testPort"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /><operation name="Add"><soap:operation soapAction="urn:test#webservice#Add" /><input><soap:body use="encoded" namespace="urn:test" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /></input><output><soap:body use="encoded" namespace="urn:test" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /></output></operation><operation name="HelloWorld"><soap:operation soapAction="urn:test#webservice#HelloWorld" /><input><soap:body use="encoded" namespace="urn:test" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /></input><output><soap:body use="encoded" namespace="urn:test" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /></output></operation></binding><service name="test"><documentation /><port name="testPort" binding="tns:testBinding"><soap:address location="http://10.0.0.51:80/creat_wsdl.php" /></port></service><message name="AddRequest"><part name="a" type="xsd:string" /><part name="b" type="xsd:string" /></message><message name="AddResponse"><part name="Add" type="xsd:string" /></message><message name="HelloWorldRequest"></message><message name="HelloWorldResponse"><part name="HelloWorld" type="xsd:string" /></message></definitions>
client.php
<?phpini_set("soap.wsdl_cache_enabled", "0");$soap = new SoapClient("webservice.wsdl");echo $soap->Add('2', '4').'<br>'; // no displayecho $soap->bbbbb().'<br>'; // no displayvar_dump($soap->__getFunctions()); // can get function//=== no use WSDL , it's work ===========================$soap = new SoapClient(null, array("location" => "http://10.0.0.51/server.php","uri" => "abcd"));echo '<br>'.$soap->bbbbb();?>
Internet example explanation client.php use first and second "echo" can be display data
but it always only third "echo" can be display data....I don't know why
I look log, it's not print any error , use dump function that can get function
Hope anyone can helpMy English isn't very good, please don't mind.Thanks