Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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 接收包含文件\u get\u contents()的XML_Php_Xml_Web Services_File Get Contents - Fatal编程技术网

Php 接收包含文件\u get\u contents()的XML

Php 接收包含文件\u get\u contents()的XML,php,xml,web-services,file-get-contents,Php,Xml,Web Services,File Get Contents,我不熟悉这个网站,也不熟悉web服务。我试图创建一个web服务,将xml响应发送回客户端请求。我遇到的问题是,当我执行客户端请求时,浏览器挂起,最终返回时出现服务器超时错误。我已经检查了PHP.INI设置,以确保将allow\u url\u fopen设置为on。 我正在使用Zend服务器在IBMi上托管该网站。 提前感谢你的帮助 这就是我试图做到的: 服务器端:该文件名为XML3.php <?php ob_start(); header("Content-Type:text/xml");

我不熟悉这个网站,也不熟悉web服务。我试图创建一个web服务,将xml响应发送回客户端请求。我遇到的问题是,当我执行客户端请求时,浏览器挂起,最终返回时出现服务器超时错误。我已经检查了PHP.INI设置,以确保将allow\u url\u fopen设置为on。 我正在使用Zend服务器在IBMi上托管该网站。 提前感谢你的帮助

这就是我试图做到的:

服务器端:该文件名为XML3.php

<?php
ob_start();
header("Content-Type:text/xml");
echo "<?xml version='1.0' encoding='UTF-8' ?>";
echo '<posts>';
    echo '<post>';
    echo "<title>title1</title>";
    echo "<body>this is the body</body>";
    echo "<post_date>02/10/2012</post_date>";
    echo '</post>';
echo '</posts>';
ob_end_flush();

?>

客户端:

<?php 
$xml = file_get_contents('http://corvetteamericadealers.com/dev1/Examples/XML3.php');
$sxe = new SimpleXMLElement($xml);
var_dump($sxe); 

您是通过解析soap xml来实现web服务的吗?使用一些web服务机制从.wsdl文件生成类。

这段代码对我来说很好。检查一下

<?php
function curl_get_file_contents($URL)
{
        $c = curl_init();
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($c, CURLOPT_URL, $URL);
        $contents = curl_exec($c);
        curl_close($c);

        if ($contents) return $contents;
            else return FALSE;
 }

$xmlString = curl_get_file_contents("http://corvetteamericadealers.com/dev1/Examples/XML3.php");
$xml = simplexml_load_string($xmlString);
var_dump($xml); 
?>

执行新的simplexmlement($url,0,true)。而且也不需要输出缓冲。我希望使用REST类型的web服务谢谢…我必须在PHP INI中设置一些不正确的内容,因为此代码也挂起。我将深入研究PHPINI,看看是否有什么需要更改的地方。
object(SimpleXMLElement)#1 (1) 
{ ["post"]=> object(SimpleXMLElement)#2 (3) 
{ 
["title"]=> string(6) "title1" 
["body"]=> string(16) "this is the body" 
["post_date"]=> string(10) "02/10/2012" } 
}