file_get_contents()没有响应 - php

sta*_*low 3 php web-services

我试图调用一个基本上看起来像这样的Web服务:

http://10.10.10.10:8080/gw/someAction?amount=10&description='Some description'
Run Code Online (Sandbox Code Playgroud)

这就是我称之为Web服务的方式:

$endpoint = "http://10.10.10.10:8080/gw/someAction?amount=10&description='Some description'";

    $opts = array('http' =>
            array(
                    'method' => 'GET',
                    'header'  => 'Content-type: application/xml'
            )
    );

    $context  = stream_context_create( $opts );

    $result = file_get_contents( $endpoint, false, $context );
    $xml_result = simplexml_load_string( $result );
    echo $xml_result->success;
Run Code Online (Sandbox Code Playgroud)

所以在这里,我什么都没有,xml_result是空的.这是有趣的部分 - 当我从描述中删除空格时:

 http://10.10.10.10:8080/gw/someAction?amount=10&description='Somedescription'
Run Code Online (Sandbox Code Playgroud)

一切都很好,我从网络服务得到答案.还尝试使用chrome rest客户端调用Web服务和描述中的空白区域,一切正常,我有回复.所以这导致我在这里使用Web服务中的空格来处理某种PHP问题.请帮忙 !

更新:

print_r($result)
Run Code Online (Sandbox Code Playgroud)

结果是

1
Run Code Online (Sandbox Code Playgroud)

Wer*_*nze 5

这不是有效的URL,必须转义空格:

http://10.10.10.10:8080/gw/someAction?amount=10&description='Some%20description'
Run Code Online (Sandbox Code Playgroud)

您可能想看一下如何在PHP中正确地对字符串进行URL编码?.