发上来
带三个文件哈,一个server.php
一个client.php
一个wsdl文件。
求助啊。。晕哦

解决方案 »

  1.   

    把3个文件同放在soap目录下,注意php.ini 去掉wsdl的缓存配置,要不改了wsdl,程序还是读原来的缓存文件.soapclient.php
    =====================================================
    <?php
    $soapClient = new SoapClient("http://localhost/soap/hello.wsdl",array("login"=>"admin","password"=>"123456"));echo $soapClient->hw('hello','world');?>
    soapserver.php
    =========================================
    <?php
    if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
    !($_SERVER['PHP_AUTH_USER']=='admin' && $_SERVER['PHP_AUTH_PW']=='123456')) {
        header('WWW-Authenticate: Basic realm="WEBSERVICE"');                  
        header("HTTP/1.0 401 Unauthorized");
        echo "You must enter a valid login ID and password to access this resource\n";
    die;
    }
    class serverClass
    {
        function hw($name,$pass)
        {
    return $name." ".$pass;
        }
    }
    $soapServer = new SoapServer("hello.wsdl");
    $soapServer->setClass('serverClass');
    $soapServer->handle();
    ?>hello.wsdl 
    wsdl的详细文档配置信息去w3cschool研究下。
    ==============================================
    <?xml version ='1.0' encoding ='UTF-8' ?>
    <definitions name='lake' targetNamespace='http://localhost/soap/' xmlns:tns='http://localhost/soap/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns='http://schemas.xmlsoap.org/wsdl/'><message name='getRequest'>
    <part name='name' type='xsd:string'/>
    <part name='pass' type='xsd:string'/>
    </message><message name='getResponse'> <part name='Result' type='xsd:string'/>
    </message><portType name='class'>
    <operation name='hw'>
    <input message='tns:getRequest'/>
    <output message='tns:getResponse'></output>
    </operation>
    </portType><binding name='class' type='tns:class'>
    <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
    <operation name='hw'>
    <soap:operation soapAction=''/>
    <input>
    <soap:body namespace="xmlns:tns" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </input>
    <output>
    <soap:body namespace="xmlns:tns" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
    </output>
    </operation>
    </binding><service name='class'>
    <port name='goforsoap' binding='class'>
    <soap:address location='http://localhost/soap/soapserver.php'/>
    </port>
    </service>
    </definitions>
      

  2.   

    你哪个wsdl怎么生成的啊?
    用zend 吗?
      

  3.   

    我自己用zend生成一个wsdl一用就挂了呢,,这个是我的<?xml version='1.0' encoding='UTF-8'?><!-- WSDL file generated by Zend Studio. --><definitions name="b1" targetNamespace="urn:b1" xmlns:typens="urn:b1" 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="hw">
    <part name="name"/>
    <part name="pass"/>
    </message>
    <message name="hwResponse">
    <part name="hwReturn"/>
    </message>
    <portType name="serverClassPortType">
    <operation name="hw">
    <input message="typens:hw"/>
    <output message="typens:hwResponse"/>
    </operation>
    </portType>
    <binding name="serverClassBinding" type="typens:serverClassPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="hw">
    <soap:operation soapAction="urn:serverClassAction"/>
    <input>
    <soap:body namespace="urn:b1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </input>
    <output>
    <soap:body namespace="urn:b1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </output>
    </operation>
    </binding>
    <service name="b1Service">
    <port name="serverClassPort" binding="typens:serverClassBinding">
    <soap:address location="http://localhost/soap/soapserver.php"/>
    </port>
    </service>
    </definitions>
      

  4.   

        *   RPC Style -- 表明http body为soap format
              o The RPC style specifies that the <soap:body> contains an element with the name of the Web method being invoked. This element in turn contains an entry for each parameter and the return value of this method.     * Document Style -- 需要server端程序解析http body
              o The message parts appear directly under the <soap:body> element. There are no SOAP formatting rules for what the <soap:body> contains.  The server application is responsible for mapping the server objects (parameters, method calls, and so forth) and the values of the XML documents.所以
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    应改为
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      

  5.   

    多到http://www.w3school.com.cn/去看看soap,wsdl相关教程。