2011-07-21 25 views
1

我想通过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限制,所以试图在您的机器上运行此代码将无法完全相同。你会/应该得到一个错误回应。

+0

你是通过Quercus运行的吗? – Bitmap

回答

0

我已经把java文件放在我的服务器env路径中。另外,使用/jdk1.6.0_14/bin/java SOAPClient4XG http://......作为它的绝对路径也起作用。