原文: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的几种方法的更多相关文章

  1. C#调用webService的几种方法

    转自: WebClient 用法小结 http://www.cnblogs.com/hfliyi/archive/2012/08/21/2649892.html http://www.cnblogs. ...

  2. 通用的调用WebService的两种方法。(调用别人提供的wsdl)(转)

    转载自:http://blog.sina.com.cn/s/blog_65933e020101incz.html1.调用WebService的Client端采用jax-ws调用WebService:流 ...

  3. Jquery调用webService的四种方法

    1.编写4种WebService方法 [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(Conf ...

  4. Jquery调用webService的四种方法 转载-记录

    我总结几个关键点 1. 服务必须声明为ScriptService(否则会出现下面的问题) 2.服务的方法不需要任何更改,保持原状 3.客户端用jquery的.ajax方法来调用 3.1 type必须是 ...

  5. asp.net远程调用WebService的两种方法(转载)

    一,静态方法在“解决方案‘项目名’” -> 相应的文件夹,如“Web References” ->右键“添加WEB引用”->在URL里写入地址.二,动态方法在“解决方案‘项目名’” ...

  6. java调用webservice接口 几种方法

    webservice的 发布一般都是使用WSDL(web service descriptive language)文件的样式来发布的,在WSDL文件里面,包含这个webservice暴露在外面可供使 ...

  7. [转]Delphi调用cmd的两种方法

    delphi调用cmd的两种方法vars:string;begins:='cmd.exe /c '+edit1.Text+' >c:\1.txt';winexec(pchar(s),sw_hid ...

  8. C++调用DLL有两种方法——静态调用和动态调用

    C++调用DLL有两种方法——静态调用和动态调用 标签: dllc++winapinullc 2011-09-09 09:49 11609人阅读 评论(0) 收藏 举报  分类: cpp(30)  [ ...

  9. C# 调用WebService的3种方式 :直接调用、根据wsdl生成webservice的.cs文件及生成dll调用、动态调用

    1.直接调用 已知webservice路径,则可以直接 添加服务引用--高级--添加web引用 直接输入webservice URL.这个比较常见也很简单 即有完整的webservice文件目录如下图 ...

随机推荐

  1. 在Mybatis中使用注解@多个參数查询

    @Select("SELECT * FROM wc_homework WHERE organization_id=#{classId} ORDER BY createtime DESC LI ...

  2. 初尝Java序列化/反序列化对象

    看个类: package com.wjy.bytes; import java.io.Serializable; public class ObjTest implements Serializabl ...

  3. Filter基金会

    一个.总结 简单的说,Filter的作用就是拦截(Tomcat的)service(Request,Response)方法.拿到Request.Response对象进行处理.然后释放控制.继续自己主动流 ...

  4. WPF界面设计技巧(3)—实现不规则动画按钮

    原文:WPF界面设计技巧(3)-实现不规则动画按钮 发布了定义WPF按钮的教程后,有朋友问能否实现不规则形状的按钮,今天我们就来讲一下不规则按钮的制作. 不规则按钮的做法实际上和先前我们做不规则窗体的 ...

  5. Linux 文件系统(二)---运行过程及结构间的关系

    (内核2.4.37) 一.首先.看看磁盘.超级块,inode节点在物理上总体的分布情况: (图示来自:www.daoluan.net) 对于一个分区,相应一个文件系统,一个文件系统事实上本质上还是磁盘 ...

  6. Context Switch and System Call

    How many Context Switches is “normal”? This depends very much on the type of application you run. If ...

  7. Windows下Putty连接虚拟机Ubuntu

    本文的题目是Windows下使用Putty连接虚拟机中的Ubuntu. 事实上针对这种一个问题,已经有非常多的文章.blog能够參考和学习.可是在本人的学习过程中还是遇到可非常多的问题. 特写下自己的 ...

  8. mysql经常使用的命令

    如何登陆数据库     飞机着陆     mysql -u <username> -p     访问本机数据库     mysql -u <username> -D <d ...

  9. windows phone 加速计(5)

    原文:windows phone 加速计(5) 在windows phone 中存在着加速计,我们可以利用加速计获得用户手机的状态,根据手机状态调整我们的程序,这样会更人性化:windows phon ...

  10. Android Wear 数据类型和接口的发送和同步数据概述

    Android Wear数据层API,这是google play service部分,通信信道,以你的手持设备和耐磨应用. Api它包含一系列数据对象,可以让系统通过监控和通知行app重要的事件数据层 ...