Message = SoapFault exception: [SOAP-ENV:Server] Procedure 'ia' not present in E:\wamp\www\ws\ServerTest1.php:11 Stack trace: #0 E:\wamp\www\ws\ServerTest1.php(11): SoapClient->__soapCall('theSun', Array) #1 {main}
<?php
$soap= new SoapClient('http://localhost/ws/Server1.wsdl');
//print_r($soap->getName());exit();
//var_dump($soap->getName());exit();
echo $soap->getName().""; //输入姓名
echo "<br>";
echo $soap->setID(1001);
echo "<br>";
try {
$param=array('ia'=>1,'ib'=>2);
echo $soap->__soapCall('theSun',array($param));
} catch (Exception $e) {
printf("Message = %s",$e->__toString());
}
?>
<?php
/**
* @author kxgtop
*
*/
class SimpleClass
{
/**
* @return string
*/
function getName()
{
return "My name is HuGe";
}
/**
* @param string $id
* @param string $name
* @return string
*/
function setID($id)
{
return "The ID IS:".$id;
}
/**
* @param integer $ia
* @param integer $ib
* @return integer
*/
function theSun($ia,$ib)
{//echo $ia;
// $arr = explode(',',$ia);
// $all = floatval($arr[0])+floatval($arr[1]);
return $ia+$ib;
}
}
$server = new SoapServer( 'Server1.wsdl');
$server-> setClass( 'SimpleClass');
$server-> handle();
?>
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost/ws/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ws" targetNamespace="http://localhost/ws/">
<wsdl:types>
<xsd:schema targetNamespace="http://localhost/ws/">
<xsd:element name="getName">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getNameResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="setId">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="setIdResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="theSun">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="theSunResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="int"></xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getNameRequest">
</wsdl:message>
<wsdl:message name="getNameResponse">
<wsdl:part name="name" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="setIdRequest">
<wsdl:part name="id" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="setIdResponse">
<wsdl:part name="newid" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="theSunRequest">
<wsdl:part name="ia" type="xsd:integer"></wsdl:part>
<wsdl:part name="ib" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="theSunResponse">
<wsdl:part name="newsun" type="xsd:integer"></wsdl:part>
</wsdl:message>
<wsdl:portType name="ws">
<wsdl:operation name="getName">
<wsdl:input message="tns:getNameRequest"/>
<wsdl:output message="tns:getNameResponse"/>
</wsdl:operation>
<wsdl:operation name="setId">
<wsdl:input message="tns:setIdRequest"></wsdl:input>
<wsdl:output message="tns:setIdResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="theSun">
<wsdl:input message="tns:theSunRequest"></wsdl:input>
<wsdl:output message="tns:theSunResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="wsSOAP" type="tns:ws">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getName">
<soap:operation soapAction="http://localhost/ws/getName" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="setId">
<soap:operation soapAction="http://localhost/ws/setId" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="theSun">
<soap:operation soapAction="http://localhost/ws/theSun" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="tns:wsSOAP" name="wsSOAP">
<soap:address location="http://localhost/ws/Server1.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>