php调用webservice的几种方法
1.WSDL模式:
$soap = new SoapClient("http://192.168.6.69:8899/Service1.asmx?wsdl");
$result2 = $soap->HelloWorld(array(
'myName'=>'aaa',
'youName'=>'bbb'
));
print_r($result2);
2.non-WSDL模式:
2.1使用SoapParam传递参数:
$soap = new SoapClient(null,array('location'=>'http://192.168.6.72:8036/Service1.asmx','uri'=>'http://tempuri.org/'));
$result2 = $soap->__soapCall("HelloWorld",
array(new SoapParam("aaa", "myName"),new SoapParam("bbb", "youName")),
//array(new SoapParam("aaa", "ns1:myName"),new SoapParam("bbb", "ns1:youName")),
array('soapaction'=>'http://tempuri.org/HelloWorld'));
print_r($result2);
2.2使用SoapVar传递参数
$ns = 'http://tempuri.org/';
$soap = new SoapClient(null,array('location'=>'http://192.168.6.72:8036/Service1.asmx','uri'=>$ns));
$result2 = $soap->__soapCall("HelloWorld",
array(new SoapVar("AAA", XSD_STRING, null, $ns, "myName", $ns),
new SoapVar("GBBB", XSD_STRING, null, $ns, "youName", $ns)),
array('soapaction'=>'http://tempuri.org/HelloWorld'));
print_r($result2);
3.添加安全Header
$soap = new SoapClient(null,array('location'=>'http://192.168.6.47/onvif/device_service','uri'=>'http://www.onvif.org/ver10/device/wsdl/'));
//ws
$ns_wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";//WS-Security namespace
$ns_wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";//WS-Security namespace
$userT = new SoapVar('admin', XSD_STRING, NULL, $ns_wsse, NULL, $ns_wsse);
$passwT = new SoapVar('NnYZe7oD81Kd8QRS4tUMze/2CUs=', XSD_STRING, NULL, $ns_wsse, NULL, $ns_wsse);
$createdT = new SoapVar(time(), XSD_DATETIME, NULL, $ns_wsu, NULL, $ns_wsu);
class UsernameT1 {
private $Username;
//Name must be identical to corresponding XML tag in SOAP header
private $Password;
// Name must be identical to corresponding XML tag in SOAP header
private $Created;
function __construct($username, $password, $created) {
$this->Username=$username;
$this->Password=$password;
$this->Created=$created;
}
}
$tmp = new UsernameT1($userT, $passwT, $createdT);
$uuT = new SoapVar($tmp, SOAP_ENC_OBJECT, NULL,
$ns_wsse, 'UsernameToken', $ns_wsse);
class UserNameT2 {
private $UsernameToken;
//Name must be identical to corresponding XML tag in SOAP header
function __construct ($innerVal){
$this->UsernameToken = $innerVal;
}
}
$tmp = new UsernameT2($uuT);
$userToken = new SoapVar($tmp, SOAP_ENC_OBJECT, NULL, $ns_wsse, 'UsernameToken', $ns_wsse);
$secHeaderValue=new SoapVar($userToken, SOAP_ENC_OBJECT, NULL,
$ns_wsse, 'Security', $ns_wsse);
$secHeader = new SoapHeader($ns_wsse, 'Security', $secHeaderValue);
$result2 = $soap->__soapCall("GetDeviceInformation",array(),null,$secHeader);
echo $result2;
php调用webservice的几种方法的更多相关文章
- C#调用webService的几种方法
转自: WebClient 用法小结 http://www.cnblogs.com/hfliyi/archive/2012/08/21/2649892.html http://www.cnblogs. ...
- 通用的调用WebService的两种方法。(调用别人提供的wsdl)(转)
转载自:http://blog.sina.com.cn/s/blog_65933e020101incz.html1.调用WebService的Client端采用jax-ws调用WebService:流 ...
- Jquery调用webService的四种方法
1.编写4种WebService方法 [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(Conf ...
- Jquery调用webService的四种方法 转载-记录
我总结几个关键点 1. 服务必须声明为ScriptService(否则会出现下面的问题) 2.服务的方法不需要任何更改,保持原状 3.客户端用jquery的.ajax方法来调用 3.1 type必须是 ...
- asp.net远程调用WebService的两种方法(转载)
一,静态方法在“解决方案‘项目名’” -> 相应的文件夹,如“Web References” ->右键“添加WEB引用”->在URL里写入地址.二,动态方法在“解决方案‘项目名’” ...
- java调用webservice接口 几种方法
webservice的 发布一般都是使用WSDL(web service descriptive language)文件的样式来发布的,在WSDL文件里面,包含这个webservice暴露在外面可供使 ...
- [转]Delphi调用cmd的两种方法
delphi调用cmd的两种方法vars:string;begins:='cmd.exe /c '+edit1.Text+' >c:\1.txt';winexec(pchar(s),sw_hid ...
- C++调用DLL有两种方法——静态调用和动态调用
C++调用DLL有两种方法——静态调用和动态调用 标签: dllc++winapinullc 2011-09-09 09:49 11609人阅读 评论(0) 收藏 举报 分类: cpp(30) [ ...
- C# 调用WebService的3种方式 :直接调用、根据wsdl生成webservice的.cs文件及生成dll调用、动态调用
1.直接调用 已知webservice路径,则可以直接 添加服务引用--高级--添加web引用 直接输入webservice URL.这个比较常见也很简单 即有完整的webservice文件目录如下图 ...
随机推荐
- SonarQube升级
1.阅读SonarQube更新日志: http://docs.codehaus.org/display/SONAR/Upgrading#Upgrading-ReleaseUpgradeNotes 2. ...
- FZU 1686(重复覆盖)
题目连接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=31370 题意:用尽量少r*c的小矩形覆盖大矩形n*m中的所有1,将 ...
- hdu 4465 Candy(2012 ACM-ICPC 成都现场赛)
简单概率题,可以直接由剩余n个递推到剩余0个.现在考虑剩余x个概率为(1-p)的candy时,概率为C(2 * n - x, x) * pow(p, n + 1) *pow(1 - p, n - x ...
- openwrt教程 第一章 物联网&openwrt开发概述
1.1 我们的宗旨 互联网.移动互联网的时代已经过去,物联网的时代已经来临!2014年,是物联网元年,2016年,物联网将达到高潮!为了迎接该潮流,我们工作室(F403科技创意室:http://f40 ...
- 【HDU】5248-序列变换(贪心+二分)
二分枚举长度改变的长度即可了 #include<cstdio> #include<cstring> #include<algorithm> using namesp ...
- Preview of Spring-framework :Spring框架的预习和自我整理
Spring简介 - 预习的自我整理 1. What's Spring? Spring是一个从实际开发中抽取出来的框架,完成了大量开发中的通用步骤,留给开发者仅仅是与特定应用相关的部分,从而提高了企业 ...
- NSUserDefaults写作和阅读对象定义自己
需要编写对象必须实现NSCoding protocol Person Class Person.h #import <Foundation/Foundation.h> #import &q ...
- JSP生成word文件
1.jsp生成word文件,直接改动jsp格式: <%@ page contentType="application/vnd.ms-word;charset=GB2312"% ...
- C++转让Lua
转载请注明出处:http://blog.csdn.net/zhy_cheng/article/details/39756423 我使用的cocos2d-x版本号是2.3.3.先在一个C++projec ...
- winzip15.0许可证
username:Juzhaofeng 授权码:MPZRP-Y7LWW-K1DKG-FM92E-2C5F5-ZEKFF