php使用SOAP1.2例子
2015-08-08 14:50
956 查看
$soap_url = 'http://192.168.8.2222:9204/MallerService.svc?wsdl ; $client = new SoapClient($soap_url, array('connection_timeout' => 20,'soap_version'=>SOAP_1_2)); $actionHdr[] = new SoapHeader("http://www.w3.org/2005/08/addressing", 'Action', 'http://tempuri.org/IMallerService/GetShortUserInfo'); $actionHdr[] = new SoapHeader("http://www.w3.org/2005/08/addressing", 'To', 'http://192.168.8.2222:9204/MallerService.svc', 1); $client->__setSoapHeaders($actionHdr); $params = array("username"=>"xx","pwd"=>"ww") ; $obj = new Object(); $obj->message = json_encode($params); $response = $client->GetShortUser($obj); $return_json = $response->GetShortUserResult; $result = json_decode($return_json);
重点是
$actionHdr[] = new SoapHeader("http://www.w3.org/2005/08/addressing", 'Action', 'http://tempuri.org/IMallerService/GetShortUserInfo'); $actionHdr[] = new SoapHeader("http://www.w3.org/2005/08/addressing", 'To', 'http://192.168.8.2222:9204/MallerService.svc', 1);
这两句,如不写会报
由于 AddressFilter 在 EndpointDispatcher 不匹配,To 为“”的消息无法在接收方处理。请检查发送方和接收方的 EndpointAddresses 是否一致。
如果报
Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.
要设置SoapClient为soap_version=>SOAP_1_2
相关文章推荐
- PHP解决Curl的毫秒超时的问题
- php绘图
- PHP实现根据图片色界在不同位置加水印的方法
- PHP 无限分类三种方式,非函数的递归调用![兄弟连]
- PHP合并两个数组的两种方式的异同
- Eclipse的PHP插件PHPEclipse安装和使用
- 修改ECSHOP的广告链接地址affiche.php为普通链接
- PHPCMS V9添加模板自定义全局变量
- PHP执行系统命令简介
- php preg_match 过滤字符
- PHP中$_FILES的使用及注意事项
- PHP弱类型:WordPress Cookie伪造
- PHP魔术函数、魔术常量、预定义常量
- PHP 如何启动用户进程
- php-windows环境搭建
- PHP中使用XML-RPC构造Web Service简单入门
- php 生成饼状图,折线图,条形图 通用类 2
- php 生成饼状图,折线图,条形图 通用类
- TP开启令牌验证
- (五)面向对象的设计原则之一