1

XMLを使用して「HelloWorld」を出力しようとしていますが、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()
#3 {main}がC:\ wamp \ www \ Web_Service \ SampleXML\index.phpにスローされます4行目

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();

?>

コードに何かが足りませんでしたか?

4

4 に答える 4

4

この行を設定しようとすると、

ini_set("default_socket_timeout", 200);

またはこれをphp.iniに入れます

 default_socket_timeout = 200
于 2013-05-07T13:59:24.190 に答える
1

集中的な SOAP 呼び出しでこの問題が発生しました。ソリューションは、apache の httpd.conf で KeepAlive をオフに切り替えます。

httpd.conf に KeepAlive Off を追加し、apache を再起動します。

于 2014-04-16T09:11:33.590 に答える