客户端代码:
$web_clent=array(
"uri"=>'http://172.16.32.60/webservice/server1.wsdl',
 "location"=>'http://172.16.32.60/webservice/index.php?wsdl',
                     "trace"=>true

);  $obj_client=new SoapClient("server1.wsdl",$web_clent);
 
 try{
 
 
   $result=$obj_client->returnString();
 
 }catch(Exception $e){
 
 
 }
echo $result;
print_r($obj_client->__getFunctions());
print_r($obj_client->__getTypes());
echo "<br/>";

echo $obj_client->fun_foo();

解决方案 »

  1.   

    错误信息:
    Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "server1.wsdl" in D:\Server files\www\interface\index.php on line 9Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'server1.wsdl' : failed to load external entity "server1.wsdl" in D:\Server files\www\interface\index.php:9 Stack trace: #0 D:\Server files\www\interface\index.php(9): SoapClient->SoapClient('server1.wsdl', Array) #1 {main} thrown in D:\Server files\www\interface\index.php on line 9
      

  2.   

    服务器代码:require_once 'basic.php';  
     function fun_foo(){

       return "test";

    } $arr_obj=array("uri"=>'http://172.16.32.60/webservice/server1.wsdl','encoding'=>'utf-8','soap_version' => SOAP_1_2 );
     
    $obj_service=new SoapServer("server1.wsdl",$arr_obj);

    $obj_service->setClass("Basic");
    //$obj_service->addFunction("fun_foo");
    $obj_service->handle();basic.phpclass Basic{
      
       public function returnString(){
      
      
       return "this is my webservice";
       }
       public function returnInt($a,$b){
      
       return $a+$b;
      
       }
       public  function Center_getCenterScheme($cinemacode){

    return array(
      "Clipuuid"=> 'uid',
    "Clipname"=>'clipname',
    "cliptime"=>'time'
      );
    server1.wsdl<?xml version='1.0' encoding='UTF-8'?><!-- WSDL file generated by Zend Studio. --><definitions name="server1" targetNamespace="urn:server1" xmlns:typens="urn:server1" 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/" xmlns:typens0="http://localhost/webservice/">
    <message name="Center_getCenterScheme">
    <part name="cinemacode"/>
    </message>
    <message name="Center_getCenterSchemeResponse">
    <part name="Center_getCenterSchemeReturn"/>
    </message>
    <message name="returnInt">
    <part name="a"/>
    <part name="b"/>
    </message>
    <message name="returnIntResponse">
    <part name="returnIntReturn"/>
    </message>
    <message name="returnString"/>
    <message name="returnStringResponse">
    <part name="returnStringReturn"/>
    </message>
    <portType name="BasicPortType">
    <operation name="Center_getCenterScheme">
    <input message="typens:Center_getCenterScheme"/>
    <output message="typens:Center_getCenterSchemeResponse"/>
    </operation>
    <operation name="returnInt">
    <input message="typens:returnInt"/>
    <output message="typens:returnIntResponse"/>
    </operation>
    <operation name="returnString">
    <input message="typens:returnString"/>
    <output message="typens:returnStringResponse"/>
    </operation>
    </portType>
    <binding name="BasicBinding" type="typens:BasicPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="Center_getCenterScheme">
    <soap:operation soapAction="urn:BasicAction"/>
    <input>
    <soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </input>
    <output>
    <soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </output>
    </operation>
    <operation name="returnInt">
    <soap:operation soapAction="urn:BasicAction"/>
    <input>
    <soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </input>
    <output>
    <soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </output>
    </operation>
    <operation name="returnString">
    <soap:operation soapAction="urn:BasicAction"/>
    <input>
    <soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </input>
    <output>
    <soap:body namespace="urn:server1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </output>
    </operation>
    </binding>
    <service name="server1Service">
    <port name="BasicPort" binding="typens:BasicBinding">
    <soap:address location="http://172.16.32.60/webservice/server1.wsdl"/>
    </port>
    </service>
    </definitions>
      

  3.   

      $obj_client=new SoapClient("http://172.16.32.60/webservice/index.php?wsdl");
      

  4.   

     是这个样子,但是为什么我要用server 端的方法,没有返回值呢?
      

  5.   

    真不简单呀!怎么搞过吗,现在这问题是不能调用server端的方法!真要命!
      

  6.   

    anyone help me ??
    用  __getFunctions()能出现方法信息,但就是调用不了!!