一个很奇怪的soap问题
新装的系统,apache根目录在/var/www/html下,
phpclient.php代码:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$soap = new SoapClient("http://localhost/soap.wsdl");
var_dump ( $soap->__getFunctions () );
echo $soap->Add(1,2);
?>
soap.php代码:
<?php
class service
{
public function HelloWorld()
{
return "Hello";
}
public function Add($a,$b)
{
return $a+$b;
}
}
$server=new SoapServer("http://localhost/soap.wsdl",array('soap_version' => SOAP_1_2));
$server->setClass("service");
$server->handle();
?>
soap.wsdl代码:
<?xml version="1.0" ?>
<definitions name="myservice" targetNamespace="urn:myservice" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:myservice" 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="myservicePort"><operation name="HelloWorld">
<input message="tns:HelloWorldRequest" />
<output message="tns:HelloWorldResponse" />
</operation>
<operation name="Add">
<input message="tns:AddRequest" />
<output message="tns:AddResponse" />
</operation>
</portType>
<binding name="myserviceBinding" type="tns:myservicePort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="HelloWorld">
<soap:operation soapAction="urn:myservice#service#HelloWorld" />
<input><soap:body use="encoded" namespace="urn:myservice" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:myservice" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="Add">
<soap:operation soapAction="urn:myservice#service#Add" />
<input><soap:body use="encoded" namespace="urn:myservice" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded" namespace="urn:myservice" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="myservice">
<documentation />
<port name="myservicePort" binding="tns:myserviceBinding"><soap:address location="http://localhost:80/phpsoap/soap.php" />
</port>
</service>
<message name="HelloWorldRequest">
</message>
<message name="HelloWorldResponse">
<part name="HelloWorld" type="xsd:string" />
</message>
<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>
</definitions>
一开赛的时候