[英]Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers
我正在尝试使用XML输出“ Hello World”,但我的php页面中出现以下异常:
致命错误:未捕获的SoapFault异常:[HTTP]在C:\\ wamp \\ www \\ Web_Service \\ SampleXML \\ index.php:4中获取HTTP标头时出错:堆栈跟踪:
#0 [内部功能]:SoapClient-> _ doRequest('<?xml version =“ ...','http:// localhos ...','urn:localhost-s ...',1,0 )
#1 [内部功能]:SoapClient-> _call('getHelloWorld',Array)
#2 C:\\ wamp \\ www \\ Web_Service \\ SampleXML \\ index.php(4):SoapClient-> getHelloWorld()
在第4行的C:\\ wamp \\ www \\ Web_Service \\ SampleXML \\ index.php中抛出#3 {main}
index.php
<?php
$client = new SoapClient('service.wsdl');
$response = $client->getHelloWorld();
echo $response;
?>
service.wsld
<?xml version = '1.0' encoding = 'UTF-8' ?>
<definitions name = "Web Service"
targetNamespace = 'http://example.org/service'
xmlns:tns = 'http://example.org/service'
xmlns:soap = 'http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd = 'http://www.w3.org/2001/XMLSchema'
xmlns:soapenc = 'http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl = 'http://schemas.xmlsoap.org/wsdl/'
xmlns = 'http://schemas.xmlsoap.org/wsdl/' >
<!-- Message -->
<message name='getHelloWorld'>
<part name='response' type='xsd:string' />
</message>
<!-- Operations offered -->
<portType name = 'PortType'>
<operation name = 'getHelloWorld'>
<!-- Target Name Space -->
<output message = 'tns:getHelloWorld' />
</operation>
</portType>
<!-- Binding Element -->
<binding name = 'Binding' type = 'tns:PortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' />
<operation name='getHelloWorld'>
<soap:operation soapAction = 'urn:localhost-service#getHelloWorld' />
<!-- Output -->
<output>
<soap:body use='encoded' namespace='urn:locahost-service' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
</output>
</operation>
</binding>
<!-- Define the service -->
<service name='Service'>
<port name='Port' binding='Binding' >
<!-- Location -->
<soap:address location='http://localhost/Web_Service/SampleXML/soap-server.php' />
</port>
</service>
</definitions>
soap-server.php
<?php
function getHelloWorld() {
return "Hello World";
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer('service.wsdl');
$server->addFunction("getHelloWorld");
$server->handle();
?>
我错过了代码中的某些内容吗?
尝试设置这条线,
ini_set("default_socket_timeout", 200);
或将其放在php.ini中
default_socket_timeout = 200
我想为时已晚,但是我有同样的问题。 我尝试了套接字超时,但是它不起作用。 我的问题是客户端和服务器在同一台物理服务器中。 当客户端代码在同一台物理服务器上工作时,出现此错误,但是,将相同的客户端代码移到我的本地主机,请求服务器(客户端和服务器在两种不同的机制中执行)都可以正常工作。
也许可以帮助别人!
我在密集的SOAP调用中遇到了这个问题,该解决方案将apache中的httpd.conf中的KeepAlive隔离开了。
将KeepAlive Off添加到httpd.conf并重新启动apache。
我只想报告在您尝试连接到服务器时触发了此错误,并且该服务器以无效数据答复或根本不答复。
增加超时可能会有所帮助,但仅在服务器响应时间过长的情况下,如您所言,您可以增加php.ini中的值
default_socket_timeout = 200
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.