简体   繁体   English

PHP readfile()返回“ HTTP / 1.1 500 Internal Server Error”

[英]PHP readfile() returns 'HTTP/1.1 500 Internal Server Error'

A have a strange problem. 有一个奇怪的问题。 There are some soap api: https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2 有一些肥皂api: https : //ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2

It works in browser fine 它可以在浏览器中正常工作

I've try to 我试图

readfile('https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2'); 

then I get HTTP/1.1 500. 然后我得到HTTP / 1.1 500。

But curl works fine too: 但是curl也可以正常工作:

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => 'https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2',
));
$resp = curl_exec($curl);
curl_close($curl);
echo $resp;

Questiong: how do you think, I can to get http 200 from that api via readfile()? 问:您如何看待,我可以通过readfile()从该api获取HTTP 200? file_get_contents() returns also 500 error. file_get_contents()也返回500错误。

ps: why readfile(), but no SoapClient: as I understand, SoapClient class incapsulates readfile() in it. ps:为什么要使用readfile(),但不能使用SoapClient:据我所知,SoapClient类将readfile()封装在其中。 So, if I get success from readfile(), than I'll try to find a solution for SoapClient. 因此,如果我从readfile()获得成功,那么我将尝试为SoapClient找到解决方案。

If I open https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2 in my browser, it does give me a HTTP 500 error (check the network tab in developer tools). 如果我在浏览器中打开https://ctaau.vedaxml.com/cta/sys2/business-enquiry-v3-2 ,它确实会给我一个HTTP 500错误(请检查开发人员工具中的“网络”标签)。

The result I'm getting is this: 我得到的结果是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>soapenv:Server</faultcode>
            <faultstring>Policy Falsified</faultstring>
            <faultactor>https://ctaau.vedaxml.com:8443/cta/sys2/business-enquiry-v3-2</faultactor>
            <detail>
                <l7:policyResult
                    status="Service Not Found.  The request may have been sent to an invalid URL, or intended for an unsupported operation." xmlns:l7="http://www.layer7tech.com/ws/policy/fault"/>
            </detail>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

Take a look at the result status message 查看结果状态消息

Service Not Found. 无法提供服务。 The request may have been sent to an invalid URL, or intended for an unsupported operation. 该请求可能已发送到无效的URL,或打算用于不受支持的操作。

Find documentation on the API and find the right service url or find out if you need to authenticate first before using the API. 查找有关API的文档,找到正确的服务URL或找出是否需要在使用API​​之前先进行身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM