结果处理程序出现问题
我正在尝试通过 PHP 运行 java 客户端,它将 XML 发送到另一台服务器。通常需要大约 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>
有没有办法让我等到 $output 有一定的价值后再继续?当我输入 isset($output) 条件时,我可以看到该变量从未设置。我尝试在条件中再次调用 shell_exec() ,但我仍然什么也没得到。
*编辑:服务器有 IP 限制,因此尝试在您的计算机上运行此代码将不会完全相同。不过,您将/应该得到错误响应。
I am trying to run a java client through PHP which sends an XML to another server. It typically takes about 10 - 30 seconds to receive the response. When I run the PHP I can tell that there is no load time so I am thinking the rest of the code executes before the response is received. I am attempting to have the return response displayed in the browser and be written to another XML in the same directory. None of this happens. The new XML is created, but is empty.
$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);
I added sleep(30)
to give the java a chance to finish before passing the value into $output
but it doesn't help. The command java SOAPClient4XG http://turbolink.turbo-marketing.net:8180 getList.xml"
works. I have used it in SOAP UI and through PUTTY by running it in the directory. The output I receive is this, in XML / SOAP format:
<?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>
Is there a way I can wait until $output has some value before moving on? When I put an isset($output)
conditional I can see that the variable is never set. I tried calling the shell_exec()
again inside the conditional but I still get nothing.
*edit: The server has IP restrictions so trying to run this code on your machine will not work exactly the same. You will / should get an error response though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已将 java 文件放入我的服务器环境路径中。另外,使用
/jdk1.6.0_14/bin/java SOAPClient4XG http://......
创建它的绝对路径也有效。I had put the java file in my server env path. Also, making an absolute path to it with
/jdk1.6.0_14/bin/java SOAPClient4XG http://......
worked as well.