简体   繁体   English

致命错误:未捕获的SoapFault异常:[HTTP]提取HTTP标头时出错

[英]Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers

I'm trying to output "Hello World" using XML but I'm getting the following exception in my php page: 我正在尝试使用XML输出“ Hello World”,但我的php页面中出现以下异常:

Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in C:\\wamp\\www\\Web_Service\\SampleXML\\index.php:4 Stack trace: 致命错误:未捕获的SoapFault异常:[HTTP]在C:\\ wamp \\ www \\ Web_Service \\ SampleXML \\ index.php:4中获取HTTP标头时出错:堆栈跟踪:
#0 [internal function]: SoapClient->_ doRequest('<?xml version="...', 'http://localhos...', 'urn:localhost-s...', 1, 0) #0 [内部功能]:SoapClient-> _ doRequest('<?xml version =“ ...','http:// localhos ...','urn:localhost-s ...',1,0 )
#1 [internal function]: SoapClient-> _call('getHelloWorld', Array) #1 [内部功能]:SoapClient-> _call('getHelloWorld',Array)
#2 C:\\wamp\\www\\Web_Service\\SampleXML\\index.php(4): SoapClient->getHelloWorld() #2 C:\\ wamp \\ www \\ Web_Service \\ SampleXML \\ index.php(4):SoapClient-> getHelloWorld()
#3 {main} thrown in C:\\wamp\\www\\Web_Service\\SampleXML\\index.php on line 4 在第4行的C:\\ wamp \\ www \\ Web_Service \\ SampleXML \\ index.php中抛出#3 {main}

index.php index.php

<?php
    $client = new SoapClient('service.wsdl');
    $response = $client->getHelloWorld(); 
    echo $response;
?>

service.wsld 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 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();

?>

Did I miss something in the code? 我错过了代码中的某些内容吗?

try to set this line, 尝试设置这条线,

ini_set("default_socket_timeout", 200);

or put this in php.ini 或将其放在php.ini中

 default_socket_timeout = 200

I suppose it's too late, but I have the same problem. 我想为时已晚,但是我有同样的问题。 I try the socket timeout but it doesn't work. 我尝试了套接字超时,但是它不起作用。 My problem was that the client and the server where in the same physical server. 我的问题是客户端和服务器在同一台物理服务器中。 With the client code working in the same physical server , I get this error, but, with the same client code moved to my localhost, requesting the server, (client and server was executed in two differents mechines) all works fine. 当客户端代码在同一台物理服务器上工作时,出现此错误,但是,将相同的客户端代码移到我的本地主机,请求服务器(客户端和服务器在两种不同的机制中执行)都可以正常工作。

Maybe that can help someone else! 也许可以帮助别人!

I had this problem with intensive SOAP calls, the solution swich off KeepAlive in httpd.conf in apache. 我在密集的SOAP调用中遇到了这个问题,该解决方案将apache中的httpd.conf中的KeepAlive隔离开了。

Add KeepAlive Off to httpd.conf and restart apache. 将KeepAlive Off添加到httpd.conf并重新启动apache。

I just want to report that this error is triggered when you try to connect to a server and this server replies with invalid data or does not reply at all. 我只想报告在您尝试连接到服务器时触发了此错误,并且该服务器以无效数据答复或根本不答复。

Increasing the timeout could be helpful but only in the context that the server is taking too long to reply, as said you can increase the value in php.ini 增加超时可能会有所帮助,但仅在服务器响应时间过长的情况下,如您所言,您可以增加php.ini中的值

default_socket_timeout = 200

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

相关问题 PHP-SoapFault异常:[HTTP]提取HTTP标头时出错 - PHP - SoapFault exception: [HTTP] Error Fetching http headers PHP-SoapClient()返回致命错误:未捕获的SoapFault异常:[xml_structure]无法将字符串解析为XML - PHP - SoapClient() returns Fatal error: Uncaught SoapFault exception: [xml_structure] String could not be parsed as XML 未捕获的SoapFault异常:[WSDL] SOAP错误:解析WSDL:无法从“ &lt;URL HERE&gt;”加载:无法加载外部实体 - Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '< URL HERE >' : failed to load external entity 未捕获的SoapFault - Uncaught SoapFault 致命错误:未捕获的DOMException:无效字符错误 - Fatal error: Uncaught DOMException: Invalid Character Error 已解决:为什么会出现“致命错误:未捕获的异常:字符串无法解析为 XML”? - SOLVED :Why am I having “Fatal error: Uncaught Exception: String could not be parsed as XML”? XML语法错误-未捕获的异常&#39;Exception&#39; - error with XML syntax - Uncaught exception 'Exception' http POST 错误 - http POST error Android Http xml错误 - Android Http xml error 生成的 Spring pom.xml 导致错误“获取 http://maven.apache.org/POM/4.0.0 时出错” - Generated Spring pom.xml causes error "Error while fetching http://maven.apache.org/POM/4.0.0"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM