关于如何调用XML的接口,求助!

浏览:2186 发布日期:2016/11/08 分类:求助交流
接口地址:http://192.168.0.32:8280/services/MP_HIS_SELECT_V_PT_DEPT_CURRENT?wsdl
请求报文:
<soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:cns="http://www.cnsesan.com"> <soapenv:Header/> <soapenv:Body> <cns:deptCurrent> <cns:PLAT_IN_NAME>?</cns:PLAT_IN_NAME> <cns:PLAT_IN_PASSWORD>?</cns:PLAT_IN_PASSWORD> <cns:MESSAGE_NO>?</cns:MESSAGE_NO> <cns:DEPT_CODE>?</cns:DEPT_CODE> </cns:deptCurrent> </soapenv:Body> </soapenv:Envelope>



调用方法

<?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 xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cns=\"http://www.cnsesan.com\">
<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 xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Text xml:lang="en-US">The endpoint reference (EPR) for the Operation not found is /services/MP_HIS_SELECT_V_PT_DEPT_CURRENT?wsdl? and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.</soapenv:Text></soapenv:Reason>
最佳答案
评论( 相关
后面还有条评论,点击查看>>