通过 cURL 的 SOAP 身份验证 PHP 返回“HTTP GET 方法未实现”500 错误


SOAP Authentication Through cURL PHP Returns "HTTP GET method not implemented" 500 error

所以我正在使用PHP cURL处理SOAP请求。我想调用操作,但在此之前我想测试身份验证部分。下面是我的代码:

$username = 'myusername';
$password = 'mypassword';
$host = 'http://xx.xx.xx.xx:xxxxx';
$process = curl_init($host);
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
curl_setopt($process, CURLOPT_HEADER, true);
curl_setopt($process, CURLOPT_HTTPHEADER, array(                                                                      
    'Content-Type: text/xml',
    "Authorization: Basic " . base64_encode($username.":".$password)
));
curl_setopt($process,CURLOPT_USERAGENT,'xxxxx/x.x');
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_VERBOSE, 1);
curl_setopt($process, CURLOPT_FAILONERROR, false);
$return = curl_exec($process);
print_r($return);
curl_close($process);

我需要使用 base64 用户名/密码。我在其他一些问题上找到了如何做到这一点。但是当我这样做时print_r($return)我收到了

HTTP/1.1 500 Internal Server Error Server: xxxxx/x.x Content-Type: text/xml; charset=utf-8 Content-Length: 883 Connection: close SOAP-ENV:Client HTTP GET method not implemented

不确定这个错误意味着什么,而且我找不到太多关于这种错误的问题。也许有人可以解释一下这里发生了什么?提前谢谢你。

错误指出您尝试访问的服务未实现 HTTPGET 功能。如果不知道您要访问的内容以及您尝试访问的 API 的文档或您尝试执行的操作的描述,则无法帮助解决错误。

通常,错误

500 是针对内部服务器错误,而不是针对您收到的未实现的错误。下面或响应代码标准的说明。

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html