无法显示 XML 页。 
使用 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。 
--------------------------------------------------------------------------------文档的顶层无效。处理资源 'http://localhost/client.php?name=DzSoft PHP Editor&[email protected]' 时出错。第 1 行,位置: 1 PHP Fatal error:  Uncaught SoapFault exception: [HTTP] Unable to parse URL in E:\program\php\soap\client.php:4
^
下面是代码
<?php
$client = new SoapClient("test.wsdl");
try {
        $result = $client->div(10,rand(0,5); // will cause a Soap Fault if divide by zero
        print “The answer is: $result”;
    } catch (SoapFault $exception) {
    echo $exception;
  }
?>
<?php
/**
* A simple math utility class
* @author Zhao
 */
class math
{  /**
* Add two integers together
     *
* @param integer $a The first integer of the addition
* @param integer $b The second integer of the addition
* @return integer The sum of the provided integers
     */
public function add($a,$b)
{
        return $a+$b;
}
/**
* Subtract two integers from each other
     *
* @param integer $a The first integer of the subtraction
* @param integer $b The second integer of the subtraction
* @return integer The difference of the provided integers
     */
public function sub($a,$b)
{
        return $a-$b;
}
/**
* Divide two integers 
     *
* @param integer $a The first integer of the subtraction
* @param integer $b The second integer of the subtraction
* @return integer The difference of the provided integers
     */
public function div($a,$b)
{
        if($b==0)
        {
                throw new SoapFault(-1,"Cannot divide by zero!");
        }
        return $a/$b;
}
}
$server = new SoapServer("test.wsdl",array('encoding'=>'GB2312'));
$server->addClass('math');
$server->handle();
?>
<?xml version='1.0' encoding='UTF-8'?>
<!-- WSDL file generated by Zend Studio. -->
<definitions name="test" targetNamespace="urn:test" xmlns:typens="urn:test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="add">
<part name="a" type="xsd:integer"/>
<part name="b" type="xsd:integer"/>
</message>
<message name="addResponse">
<part name="addReturn" type="xsd:integer"/>
</message>
<message name="div">
<part name="a1" type="xsd:integer"/>
<part name="b1" type="xsd:integer"/>
</message>
<message name="divResponse">
<part name="divReturn" type="xsd:integer"/>
</message>
<message name="sub">
<part name="a2" type="xsd:integer"/>
<part name="b2" type="xsd:integer"/>
</message>
<message name="subResponse">
<part name="subReturn" type="xsd:integer"/>
</message>
<portType name="mathPortType">
<documentation>
A simple math utility class
</documentation>
<operation name="add">
<documentation>
Add two integers together
</documentation>
<input message="typens:add"/>
<output message="typens:addResponse"/>
</operation>
<operation name="div">
<documentation>
Divide two integers
</documentation>
<input message="typens:div"/>
<output message="typens:divResponse"/>
</operation>
<operation name="sub">
<documentation>
Subtract two integers from each other
</documentation>
<input message="typens:sub"/>
<output message="typens:subResponse"/>
</operation>
</portType>
<binding name="mathBinding" type="typens:mathPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="add">
<soap:operation soapAction="urn:mathAction"/>
<input>
<soap:body namespace="urn:test" use="literal"/>
</input>
<output>
<soap:body namespace="urn:test" use="literal"/>
</output>
</operation>
<operation name="div">
<soap:operation soapAction="urn:mathAction"/>
<input>
<soap:body namespace="urn:test" use="literal"/>
</input>
<output>
<soap:body namespace="urn:test" use="literal"/>
</output>
</operation>
<operation name="sub">
<soap:operation soapAction="urn:mathAction"/>
<input>
<soap:body namespace="urn:test" use="literal"/>
</input>
<output>
<soap:body namespace="urn:test" use="literal"/>
</output>
</operation>
</binding>
<service name="testService">
<port name="mathPort" binding="typens:mathBinding">
<soap:address location="'http://localhost/server.php"/>
</port>
</service>
</definitions>