CentOS SOAP扩展模块触发Service端执行相应的操作

系统 Linux
首先,要确保安装了CentOS SOAP扩展,没有安装的表现是,当运行使用了soapclient的代码时候会有php error Class ‘SoapClient’ not found的错误;这时候应该安装php-soap,在CentOS SOAP上可以方便的使用yum更新安装包>yum install php-soap更新过这些安装包后,需要重新启动一下apache服务.

CentOS SOAP对于电脑使用的玩家的常用软件,然后我就学习及深入的研究CentOS SOAP,在这里和大家一起探讨CentOS SOAP的使用方法,希望对大家有用。从PHP5开始内置CentOS SOAP扩展模块,通过它,我们可以方便的向Service发送一个CentOS SOAP消息,从而触发Service端执行相应的操作,并将结果返回;

首先,要确保安装了CentOS SOAP扩展,没有安装的表现是,当运行使用了soapclient的代码时候会有php error Class ‘SoapClient’ not found的错误;这时候应该安装php-soap,在CentOS SOAP上可以方便的使用yum更新安装包>yum install php-soap更新过这些安装包后,需要重新启动一下apache服务,此后SoapClient类就可以用在php script中了下边是使用过程中的一个范例:

  1. <?php 
  2. $client = new SoapClient("some.wsdl");   
  3. $client->SomeFunction($a, $b, $c);  
  4. $arr= $client->__soapCall("SomeFunction", array($a, $b, $c));   
  5. print_r($arr);  
  6. ?>  

1.in WSDL mode,soapCall应用web service,例子用的是asp.net的web service,提供service.asmx页面,调用及查看都比较简单,手册上的example也大多是这个类型,比较简单

CentOS SOAP发送的协议:

  1. POST /servicepath/service.asmx HTTP/1.1   
  2. Host: 211.186.1.4   
  3. Content-Type: text/xml; charset=utf-8   
  4. Content-Length: length   
  5. SOAPAction: "http://211.186.5.15/Service/ServiceMethod" 
  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  3.  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  4. xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">   
  5. <soap:Body>   
  6. <ServiceMethod xmlns="http://211.186.5.15/Service">   
  7. <param1>string</param1>   
  8. <param2>string</param2>   
  9. <param3>string</param3>   
  10. </ServiceMethod>   
  11. </soap:Body>   
  12. </soap:Envelope> 

调用方法:

  1. $client = new SoapClient("http://www.xxx.com/service/service.asmx?WSDL");   
  2. //向SOAP服务方发送参数值   
  3. $param1 = "p1";   
  4. $param2 = "p2";   
  5. $param3 = "p3"

//serviceParam1,serviceParam2,serviceParam3为发送参数值所对应的参数名(或service端提供的字段名) $param = array('serviceParam1' => $param1,'serviceParam2' => $param2,'serviceParam3' => $param3);

//方法名为ServiceMethod,参数数组为$param,默认以parameters字段标示传递的参数数组 $arr = $client->__soapCall('ServiceMethod',array('parameters' => $param)); print_r($arr);

此处,print_r($arr)打印出来的是一个对象,类似于

  1. stdClass Object   
  2. ( [BindValidateResult] => 01062947546 ) 

经过我多次的尝试,发现使用$arr[1],$arr[0],$arr[BindValidateResult]均不能取得有效值;后来查询到通过$arr->BindValidateResult可以访问到返回值;

【编辑推荐】

  1. CentOS Nginx服务器配置nginx.conf
  2. CentOS VM主机支持RedHat AS3/AS4/AS5Linux操作系统
  3. CentOS yum仓库使用 ISO 文件制作
  4. CentOS系统CPU过热处理的解决方法
  5. CentOS bonding技术使用奇怪的拓扑结果
责任编辑:佚名 来源: CSDN
相关推荐

2010-02-03 15:46:43

Linux iso

2010-06-10 13:45:47

openSUSE软件源

2009-12-23 17:49:28

WPF触发器

2023-06-11 16:09:49

触发器MySQL

2010-05-27 18:27:45

Linux测试工具

2010-03-02 09:59:03

Fedora Make

2010-09-10 15:04:40

SOAP HTTP

2009-06-22 10:04:00

J2EE web se

2011-03-11 12:57:30

CentosLAMP

2009-06-22 10:09:00

J2EE web se

2010-07-16 10:19:31

2010-02-22 15:33:23

Python扩展模块

2021-01-26 00:37:12

物联网安全物联网端到端安全

2010-07-14 17:29:36

SOAP协议

2009-05-25 17:40:54

Microsoft RService Con扩展

2009-10-16 09:42:06

2010-02-04 10:52:54

CentOS CPU

2023-07-13 12:27:04

2011-12-09 11:16:48

Node.js

2010-09-02 16:39:30

SOAP协议
点赞
收藏

51CTO技术栈公众号