Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Coldfusion传递XML代码以从API获得休息_Php_Xml_Api_Coldfusion - Fatal编程技术网

Php 使用Coldfusion传递XML代码以从API获得休息

Php 使用Coldfusion传递XML代码以从API获得休息,php,xml,api,coldfusion,Php,Xml,Api,Coldfusion,我有下面的PHP代码发布XML数据,并检索状态是否为成功发布。该代码是由该公司发送来测试api的,但由于使用ColdFusion进行开发,我编写了一个代码,下面在ColdFusion中给出,它会发送一个OK响应,但会根据行为或api返回一个错误代码 <?php define('blueEx', "http://benefit.blue-ex.com/api/post.php"); $xml = '<?xml version="1.0" encoding="utf-8"?> &

我有下面的PHP代码发布XML数据,并检索状态是否为成功发布。该代码是由该公司发送来测试api的,但由于使用ColdFusion进行开发,我编写了一个代码,下面在ColdFusion中给出,它会发送一个OK响应,但会根据行为或api返回一个错误代码

<?php 
define('blueEx', "http://benefit.blue-ex.com/api/post.php");
$xml = '<?xml version="1.0" encoding="utf-8"?>
<BenefitDocument>
<AccessRequest>
<DocumentType>1</DocumentType>
<TestTransaction>Y</TestTransaction>*For Testing purpose, after testing leave it blank
<ShipmentDetail>
            <ShipperName></ShipperName>
            <ShipperAddress></ShipperAddress>
            <ShipperContact></ShipperContact>
            <ShipperEmail></ShipperEmail>
            <ConsigneeName>Tayyab</ConsigneeName>
            <ConsigneeAddress>202-N,DHA,Lahore</ConsigneeAddress>
            <ConsigneeContact>03004306499</ConsigneeContact>
            <ConsigneeEmail>fusioner@gmail.com</ConsigneeEmail>
            <CollectionRequired>Y</CollectionRequired>
            <ProductDetail>Some Product</ProductDetail>
            <ProductValue>200</ProductValue>
            <OriginCity>ISB</OriginCity>
            <DestinationCountry>PK</DestinationCountry>
            <DestinationCity>LHE</DestinationCity>
            <ServiceCode>BG</ServiceCode>
            <ParcelType>P</ParcelType>
            <Peices>1</Peices>
            <Weight>1</Weight>
            <Fragile>N</Fragile>
            <ShipperReference>9010191</ShipperReference>
            <InsuranceRequire>N</InsuranceRequire>
            <InsuranceValue></InsuranceValue>
            <ShipperComment>xxxx</ShipperComment>
</ShipmentDetail>
</AccessRequest>
</BenefitDocument>';
$c = curl_init();     
    curl_setopt($c, CURLOPT_URL, blueEx );
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt($c, CURLOPT_USERPWD, "sphere.technologies:sphere.tech");
    curl_setopt($c, CURLOPT_POST, 1 );
    curl_setopt($c, CURLOPT_POSTFIELDS, array('xml'=>$xml) );
    curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type=application/soap+xml', 'charset=utf-8'));
    $result = curl_exec ($c);
    $xres = simplexml_load_string($result);
    $st = $xres->status;
    $no = $xres->message;

    echo $st . ' - ' . $no;
?>
$xml));
curl_setopt($c,CURLOPT_HTTPHEADER,array('Content-Type=application/soap+xml','charset=utf-8');
$result=curl_exec($c);
$xres=simplexml\u load\u字符串($result);
$st=$xres->状态;
$no=$xres->message;
回声$st.'-'$不
?>
并且它的工作返回了一个成功的状态

我想用ColdFusion编写代码,我编写了以下代码

<cfset objCFHttpProperties = {
    Useragent = "#CGI.http_user_agent#",
    Username = "sphere.technologies",
    Password = "sphere.tech"
    } />
<cfxml variable="xmlString">
    <BenefitDocument>
        <AccessRequest>
            <DocumentType>1</DocumentType>
            <TestTransaction>Y</TestTransaction>
        <ShipmentDetail>
            <ShipperName></ShipperName>
            <ShipperAddress></ShipperAddress>
            <ShipperContact></ShipperContact>
            <ShipperEmail></ShipperEmail>
            <ConsigneeName>Tayyab</ConsigneeName>
            <ConsigneeAddress>202-N,DHA,Lahore</ConsigneeAddress>
            <ConsigneeContact>03004306499</ConsigneeContact>
            <ConsigneeEmail>fusioner@gmail.com</ConsigneeEmail>
            <CollectionRequired>Y</CollectionRequired>
            <ProductDetail>Some Product</ProductDetail>
            <ProductValue>200</ProductValue>
            <OriginCity>ISB</OriginCity>
            <DestinationCountry>PK</DestinationCountry>
            <DestinationCity>LHE</DestinationCity>
            <ServiceCode>BG</ServiceCode>
            <ParcelType>P</ParcelType>
            <Peices>1</Peices>
            <Weight>1</Weight>
            <Fragile>N</Fragile>
            <ShipperReference>9010191</ShipperReference>
            <InsuranceRequire>N</InsuranceRequire>
            <InsuranceValue></InsuranceValue>
            <ShipperComment></ShipperComment>
        </ShipmentDetail>
    </AccessRequest>
</BenefitDocument>
</cfxml>
<cfhttp url="http://benefitx.blue-ex.com/api/post.php" method="post" result="result" attributecollection="#objCFHttpProperties#">
    <cfhttpparam type="header" name="Content-Type" value="application/soap+xml"/>
    <cfhttpparam type="xml" name="xmlString" value="#xmlString#" />
</cfhttp>
<cfdump var="#result#">

1.
Y
塔伊布
202-N,DHA,拉合尔
03004306499
fusioner@gmail.com
Y
一些产品
200
ISB
主键
LHE
背景
P
1.
1.
N
9010191
N
但此代码返回错误状态

我一直在试图解决这个问题,但无法解决。谁能帮帮我,我哪里出错了


谢谢

我希望这个帖子能对解决这个问题有所帮助。多亏了AdobeFourms的BKBK,他解决了问题


我希望此线程有助于解决此问题。多亏了AdobeFourms的BKBK,他解决了问题