2015-06-15 111 views
0

有人可以幫助我使用PHP將xml數據發送到服務器嗎?使用PHP將XML數據發送到服務器

這裏是信息

<?xml version="1.0" encoding="UTF-8"?> 
    <SOAPENV:Envelope 
    xmlns:SOAPENV="http://www.w3.org/2003/05/soap-envelope" 
     xmlns:SOAPENC="http://www.w3.org/2003/05/soap-encoding" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
      <SOAPENV:Body> 
      <JobRequest xmlns="http://81.105.223.86:80/cni"> 
       <SourceSystem>KVCARS</SourceSystem> 
       <SourcePassword>Ketchup96</SourcePassword> 
       <SourceJobID>*KV001*</SourceJobID> 
       <SourceAccount>CORDIC</SourceAccount> 
       <TargetSystem>TARGET1</TargetSystem> 
       <Lifetime>60</Lifetime> 
       <DriverNotes>Please wait at reception.</DriverNotes> 
       <OperatorNotes>Test job for CNI.</OperatorNotes> 
       <BookerName>Jane</BookerName> 
       <BookerPhone>01954233255</BookerPhone> 
       <BookerEmail>[email protected]</BookerEmail> 
       <StopList> 
       <Stop> 
        <Order>1</Order> 
        <Passenger>Fara Arani</Passenger> 
        <Address>Cordic Ltd, 1 Rowles Way, Swavesey, Cambridge</Address> 
        <Postcode>CB24 4UG</Postcode> 
        <ContactPhone>01954233255</ContactPhone> 
        <ContactOnArrive>Ring</ContactOnArrive> 
       </Stop> 
       <Stop> 
        <Order>2</Order> 
        <Address>Heathrow Airport, Terminal 4</Address> 
        <Postcode>TW6 3GA</Postcode> 
       </Stop> 
       </StopList> 
       <AttributeList> 
       <Attribute>Executive</Attribute> 
       <Attribute>Professional</Attribute> 
       </AttributeList> 
      </JobRequest> 
      </SOAPENV:Body> 
     </SOAPENV:Envelope> 

下面是你應該將消息發送到你可以用它來開發你的系統的網關的測試版本中使用的詳細信息:

URL= http://81.105.223.86:80/cni 
SourceSystem= KVCARS 
SourcePassword= Ketchup96 

您可以使用任何SourceAccount名稱,空白除外。如果您使用SourceJobType = Account,您將預訂一個帳戶作業,其他任何內容都將映射到Cash。

有測試目標系統稱爲TARGET1配置爲接收作業。目標系統有一個模擬器,可以模擬車隊(大約100輛車之一,另一輛大約50輛)。模擬車輛應該接受併發送給他們的工作。

下面是詳細信息:

Target1 URL= http://86.17.13.109:81/Webbooker 
Account= *KV001* (including the asterisks) 
User= KVCARS 
Password= Ketchup96 

回答

0

$ URL = 「http://86.17.13.109:81/Webbooker」;

//setting the curl parameters. 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 

//以下行是必須放添加,因爲它是: curl_setopt($ CH,CURLOPT_POSTFIELDS, 「xmlRequest =」 $ input_xml); curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ ch,CURLOPT_CONNECTTIMEOUT,300); $ data = curl_exec($ ch); curl_close($ ch);

//convert the XML result into array 
    $array_data = json_decode(json_encode(simplexml_load_string($data)), true); 

    print_r('<pre>'); 
    print_r($array_data); 
    print_r('</pre>'); 

參考Send XML data to a server using PHP

相關問題