<?php
function httpRequestSoapData($responseUrl,$requestXML)
{
try{
$myhttp = new HttpRequest($responseUrl."?WSDL","POST");
//--相对于API2.0固定
$r_head=<<<BEGIN
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Request xmlns="http://ctrip.com/">
<requestXML>
BEGIN;
$r_end=<<<BEGIN
</requestXML>
</Request>
</soap:Body>
</soap:Envelope>
BEGIN; //返回头
$responseHead=<<<begin
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><RequestResponse xmlns="http://ctrip.com/"><RequestResult>
begin;
//返回尾
$responseEnd=<<<begin
</RequestResult></RequestResponse></soap:Body></soap:Envelope>
begin; $requestXML=str_replace("<",@"<",$requestXML);
$requestXML=str_replace(">",@">",$requestXML); $requestXML=$r_head.$requestXML.$r_end;
$myhttp->open();
$myhttp->send($requestXML);
$myhttp->getResponseBody();
$coutw=$myhttp->getResponseBody();
$coutw=str_replace($responseHead,"",$coutw);//替换返回头
$coutw=str_replace($responseEnd,"",$coutw);//替换返回尾
$coutw=str_replace("<","<",$coutw);//将符号换回来
$coutw=str_replace(">",">",$coutw);//将符号换回来
// echo $coutw;
return $coutw;
}
catch (SoapFault $fault){
return $fault->faultcode;
}
}?>
携程机票接口写法
原创dreamboycx 博主文章分类:PHP ©著作权
©著作权归作者所有:来自51CTO博客作者dreamboycx的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:JS日期比较
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
python协程(asyncio)实现爬虫例子
使用python协程实现异步爬取网站。
python 协程 爬虫