這是csdn 的文章內容 自己留著了 感覺這種方式不太正規 但可用
client_1.php
<?php<br />$re=$soapClient = new SoapClient("http://test.cheshi.com/webservice/server_1.php?wsdl",array("login"=>"admin","password"=>"123456"));</p><p>echo $soapClient->hw('hello','world');<br />?>
server_1.php
<?php<br />error_reporting(2047);<br />ini_set("soap.wsdl_cache_enabled", "0");<br />if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||<br />!($_SERVER['PHP_AUTH_USER']=='admin' && $_SERVER['PHP_AUTH_PW']=='123456')) {<br /> header('WWW-Authenticate: Basic realm="WEBSERVICE"');<br /> header("HTTP/1.0 401 Unauthorized");<br /> echo "You must enter a valid login ID and password to access this resource/n";<br /> die;<br />}<br />class serverClass<br />{<br /> function hw($name,$pass)<br /> {<br /> return $name." ".$pass;<br /> }<br />}<br />$soapServer = new SoapServer("hello.wsdl");<br />$soapServer->setClass('serverClass');<br />$soapServer->handle();</p><p>?>
hello.wsdl
<?xml version ='1.0' encoding ='UTF-8' ?><br /><definitions name='lake' targetNamespace='http://test.cheshi.com/webservice/' xmlns:tns='http://test.cheshi.com/webservice/' 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/'></p><p><message name='getRequest'><br /> <part name='name' type='xsd:string'/><br /> <part name='pass' type='xsd:string'/><br /></message></p><p><message name='getResponse'></p><p> <part name='Result' type='xsd:string'/><br /></message></p><p><portType name='class'><br /><operation name='hw'><br /> <input message='tns:getRequest'/><br /> <output message='tns:getResponse'></output><br /></operation><br /></portType></p><p><binding name='class' type='tns:class'><br /> <soap:binding style="rpc" mce_style="rpc" transport='http://schemas.xmlsoap.org/soap/http'/><br /> <operation name='hw'><br /> <soap:operation soapAction=''/><br /> <input><br /> <soap:body namespace="xmlns:tns" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/><br /> </input><br /> <output><br /> <soap:body namespace="xmlns:tns" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /><br /> </output><br /> </operation><br /></binding></p><p><service name='class'><br /> <port name='goforsoap' binding='class'><br /> <soap:address location='http://test.cheshi.com/webservice/server_1.php'/><br /> </port><br /></service><br /></definitions>