我想通過PHP將XML發送到另一臺服務器來運行java客戶端。通常需要大約10 - 30秒才能收到響應。當我運行PHP時,我可以知道沒有加載時間,所以我想在收到響應之前執行其餘的代碼。我試圖讓瀏覽器顯示返回響應,並將其寫入同一目錄中的另一個XML。沒有發生這種情況。新的XML已創建,但爲空。結果處理程序問題
$output = shell_exec("java SOAPClient4XG http://turbolink.turbo-marketing.net:8180 getList.xml");
sleep(30);
echo $output;
$filename = "getListResult";
$filename .= ".xml";
$fp = fopen($filename, 'w');
fwrite($fp, $output);
fclose($fp);
我加sleep(30)
給java的機會傳遞值到$output
之前完成,但它並不能幫助。命令java SOAPClient4XG http://turbolink.turbo-marketing.net:8180 getList.xml"
起作用。我已經在SOAP UI中使用它,並通過在目錄中運行PUTTY來使用它。我收到的輸出是這樣的,在XML/SOAP格式:
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:getListsResponse xmlns:n1="urn:Turbolink"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getListsResult xsi:type="n1:getListsResult">
<responseMessages n2:arrayType="n1:responseMessage[1]"
xmlns:n2="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="n2:Array">
<responseMessage>
<code xsi:type="xsd:string">0</code>
<message xsi:type="xsd:string">No Error</message>
</responseMessage>
</responseMessages>
<dataLists xmlns:n3="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="n3:Array"
n3:arrayType="n1:dataList[5]">
<dataList>
<listID xsi:type="xsd:string">CVPLUS </listID>
<listDescription xsi:type="xsd:string">ConsumerVision Plus</listDescription>
<listVersion xsi:type="xsd:integer">94</listVersion>
</dataList>
<dataList>
<listID xsi:type="xsd:string">MORTHOT </listID>
<listDescription xsi:type="xsd:string">Mortgage Hotlines</listDescription>
<listVersion xsi:type="xsd:integer">206</listVersion>
</dataList>
<dataList>
<listID xsi:type="xsd:string">MRTGBASE</listID>
<listDescription xsi:type="xsd:string">Mortgage Base</listDescription>
<listVersion xsi:type="xsd:integer">94</listVersion>
</dataList>
<dataList>
<listID xsi:type="xsd:string">SUPERNEW</listID>
<listDescription xsi:type="xsd:string">American New Movers Plus</listDescription>
<listVersion xsi:type="xsd:integer">171</listVersion>
</dataList>
<dataList>
<listID xsi:type="xsd:string">TSEBUS </listID>
<listDescription xsi:type="xsd:string">TSE Business File</listDescription>
<listVersion xsi:type="xsd:integer">38</listVersion>
</dataList>
</dataLists>
</getListsResult>
</n1:getListsResponse>
有沒有一種方法可以讓我等到$輸出具有在移動之前一定的價值?當我把isset($output)
條件,我可以看到變量從未設置。我試圖在條件內再次撥打shell_exec()
,但我仍然沒有收到任何東西。
*編輯:服務器有IP限制,所以試圖在您的機器上運行此代碼將無法完全相同。你會/應該得到一個錯誤迴應。
你是通過Quercus運行的嗎? – Bitmap