请求报文:
<soapenv:Envelope xm
调用方法
<?php
header("Content-Type:text/html; charset=utf-8");
function P ($array) {
dump($array, 1 , '<pre>', 0);
}
/**
* 发送HTTP请求方法
* @param string $url 请求URL
* @param array $params 请求参数
* @param string $method 请求方法GET/POST
* @return array $data 响应数据
*/
function http($url, $params, $method = 'GET', $header = array(), $multi = false){
$opts = array(
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HTTPHEADER => $header
);
/* 根据请求类型设置特定参数 */
switch(strtoupper($method)){
case 'GET':
$opts[CURLOPT_URL] = $url . '?' . http_build_query($params);
break;
case 'POST':
//判断是否传输文件
//p(http_build_query($params));
$params = $multi ? $params : http_build_query($params);
$opts[CURLOPT_URL] = $url;
$opts[CURLOPT_POST] = 1;
$opts[CURLOPT_POSTFIELDS] = $params;
break;
default:
throw new Exception('不支持的请求方式!');
}
/* 初始化并执行curl请求 */
$ch = curl_init();
curl_setopt_array($ch, $opts);
$data = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if($error) throw new Exception('请求发生错误:' . $error);
return $data;
}
?>
代码
<?php
header("Content-Type:text/html; charset=utf-8");
class IndexAction extends Action{
public function index(){
$url = "http://192.168.0.32:8280/services/MP_HIS_SELECT_V_PT_DEPT_CURRENT?wsdl";
$data="<soapenv:Envelope xm
<soapenv:Header/>
<soapenv:Body>
<cns:deptCurrent>
<cns:PLAT_IN_NAME>WSYY</cns:PLAT_IN_NAME>
<cns:PLAT_IN_PASSWORD>cbyy+fire</cns:PLAT_IN_PASSWORD>
<cns:MESSAGE_NO>fsdsdfasdfsa</cns:MESSAGE_NO>
<cns:CONDITION>1=1</cns:CONDITION>
</cns:deptCurrent>
</soapenv:Body>
</soapenv:Envelope>";
//定义传递的参数数组;
//$data['PLAT_IN_NAME']='WSYY'; //医生号别
//$data['PLAT_IN_PASSWORD']='123123213'; //接口编号
//定义返回值接收变量;
//$json_string = json_encode($data); //JSON转换加密
//$arr= array('params'=>$data);
$httpstr = http($url, $data, 'POST'); //传递参数
p($httpstr);
//$a = json_decode($httpstr,true);
p($a);
}
}
?>
返回错误:<soapenv:Reason xm
最佳答案