php webservice 验证 另一方式
2011-03-31 16:54
204 查看
这是csdn 的帖子内容 自己留着了 感觉这种方式不太正规 但可用
client_1.php
server_1.php
hello.wsdl
client_1.php
<?php $re=$soapClient = new SoapClient("http://test.cheshi.com/webservice/server_1.php?wsdl",array("login"=>"admin","password"=>"123456")); echo $soapClient->hw('hello','world'); ?>
server_1.php
<?php error_reporting(2047); ini_set("soap.wsdl_cache_enabled", "0"); 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
<?xml version ='1.0' encoding ='UTF-8' ?> <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/'> <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" mce_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://test.cheshi.com/webservice/server_1.php'/> </port> </service> </definitions>
相关文章推荐
- WebService的两种用户验证方式
- php传值方式和ajax的验证功能
- 另外一种WebService的用户验证方式---使用验证票
- php webservice soapheader 身份验证
- WebService的几种验证方式
- PHP 调用webService方式
- 采用Soap方式的php的webservice简单实例
- Webservice加上SoapHeader验证方式
- WebService的两种用户验证方式
- php webservice中使用soapheader简单验证 实例
- WebService的两种用户验证方式
- php传值的方式和ajax的验证
- 用XFire做的带验证(Handler方式)的Webservice!!!(完整版)
- 一个验证smtp方式发送邮件的php脚本
- WebService的两种用户验证方式
- axis1.0+带证书验证方式访问webservice的问题
- WebService,ASMX文件使用XML格式数据传递参数、验证与获取XML格式返回值的一种方式
- WebService的几种验证方式
- PHP表单提交验证各种方式
- webservice的几种验证方式(一)基于JAX-WS