方法一:直接调用
/******************************************************************************/
/* 文件名 : soapclient.php
/* 说 明 : WebService接口客户端例程
/******************************************************************************/
include('NuSoap.php');
// 创建一个soapclient对象,参数是server的WSDL
$client = new soapclient('http://localhost/Webservices/Service.asmx?WSDL', 'wsdl');
// 参数转为数组形式传递
$aryPara = array('strUsername'=>'username', 'strPassword'=>MD5('password'));
// 调用远程函数
$aryResult = $client->call('login',$aryPara);
//echo $client->debug_str;
/*
if (!$err=$client->getError()) {
print_r($aryResult);
} else {
print "ERROR: $err";
}
*/
$document=$client->document;
echo <<<SoapDocument
<?xml version="1.0" encoding="GB2312"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd">
<SOAP-ENV:Body>
$document
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SoapDocument;
方法二:代理方式调用
/******************************************************************************/
/* 文件名 : soapclient.php
/* 说 明 : WebService接口客户端例程
/******************************************************************************/
require('NuSoap.php');
//创建一个soapclient对象,参数是server的WSDL
$client=new soapclient('http://localhost/Webservices/Service.asmx?WSDL', 'wsdl');
//生成proxy类
$proxy=$client->getProxy();
//调用远程函数
$aryResult=$proxy->login('username',MD5('password'));
//echo $client->debug_str;
/*
if (!$err=$proxy->getError()) {
print_r($aryResult);
} else {
print "ERROR: $err";
}
*/
$document=$proxy->document;
echo <<<SoapDocument
<?xml version="1.0" encoding="GB2312"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd">
<SOAP-ENV:Body>
$document
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SoapDocument;
分享到:
相关推荐
本实例包含php调用webservice及myeclipse创建webservice实例全部代码,简单易懂,运行绝对没有问题,文件齐全,导入即可运行,适合webservice初学者
NuSoap是PHP环境下的WebService编程工具,用于创建或调用WebService。
某些情况下我们可能需要与Mysql或者Oracle数据库进行数据交互,有些朋友的第一反应就是直接在Android中加载驱动...既然是调用WebService,我们首先的搭建WebService服务器。 下面演示的就是如何通过该网站提供的手机
客户端调用测试 client.php中,修改代码new SoapClient("http://webservice.my.com/hello.wsdl");中的域名或网址 client.php?fun=fun1 返回1个失败提示 client.php?fun=fun2 返回一个简单数组(json,下同) ...
本篇文章介绍了,PHP中如何调用webservice的实例参考。需要的朋友参考下
使用PHP调用JAVA语言开发的WebService。客户端提交两个String类型的参数,服务端返回一个对象类型。服务端使用AXIS-1.4作为SOAP引擎。客户端为PHP5.2.9,使用NuSOAP作为SOAP引擎。 服务端 对象类复制代码 代码如下:...
创建一个C#的web service,这个就不多说了,我用vs2008的wizard创建了一个最简单的,让它运行在:...在某php文件中如下写法: php5本身就支持SOAP调用Web Service: <?php //get localization strings from C# webs
作为开发者来讲,要想写webservice接口或者调用别人的webservice接口,首先需要了解什么是webservice。简单说, WebService就是一些站点开放一些服务出来, 也可以是你自己开发的Service, 也就是一些方法, 通过URL,...
主要介绍了php实现通过soap调用.Net的WebService asmx文件,结合实例形式分析了php使用soap实现WebService接口的调用技巧,需要的朋友可以参考下
最近接触到一个银行接口的案子,临时需要用到axis2 webservice。自己现学现总结的一些东西,留给新手。少走弯路。 Axis2简介 ①采用名为 AXIOM(AXIs Object Model)的新核心 XML 处理模型,利用新的XML解析器提供...
主要介绍了PHP使用SOAP调用API操作,结合实例形式分析了php基于SOAP调用API的常见操作技巧及相关问题解决方法,需要的朋友可以参考下
JAVA如何调用wsdl过程详解java WSDL接口webService实现方式PHP调用wsdl文件类型的接口代码分享解析利用wsdl.exe生成webservice代理类的详解在PHP中利用wsdl创建标准webservice的实现代码Java调用CXF WebService接口...
今天使用THINKPHP3.2 框架中开发时使用soap连接webservice 一些浅见现在分享一下, 1.首先我们要在php.ini ...3.然后调用webservice 接口方法 //获取webservice 接口方法 $client->__getFunctions (); //获取we
//详细参数说明可以参考文档 http://wiki.open.taobao.com/index.php/Taobao.taobaoke.items.get //详细分类属性ID请参考http://open.taobao.com/api_tool/props/ //网站演示:...
本文实例讲述了PHP使用NuSOAP调用Web服务的方法。分享给大家供大家参考。具体如下: Steps: 1. Download nusoap library from internet. 2. Pass parameter list in your $client->call and enjoy. <?php ...
//WebService接口里面有四个方法 //TaoBaoke //返回DataSet taobao.taobaoke.items.get:接口 //TaoBaokeObject //返回数组taobao.taobaoke.items.get:接口 //TaoBaokeObjects //返回数组taobao.taobaoke....