SoapFault:SOAP

时间:2019-02-01 09:40:41

标签: php nusoap

我正在用nusoap制作一个wsdl文件。该文件似乎是正确的,但是,当我尝试调用函数时,出现了下一个错误:

Fatal error: Uncaught SoapFault exception: [Client] DTD are not supported by SOAP

服务器的代码如下:

include('lib/nusoap.php');

$ns = 'test';

$server = new soap_server;
$server->configureWSDL('test', $ns);

$server->register('welcome',
array('name' => 'xsd:string'),
array('return' => 'xsd:string'));

function welcome($name){
    return "Welcome, " . $name;
}

$server->service('php://input');

使用?wsdl获得的生成的wsdl文件是这样的:

<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="test" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="test">
<types>
<xsd:schema targetNamespace="test">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema>
</types>
<message name="welcomeRequest">
<part name="name" type="xsd:string"/>
</message>
<message name="welcomeResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="testPortType">
<operation name="welcome">
<input message="tns:welcomeRequest"/>
<output message="tns:welcomeResponse"/>
</operation>
</portType>
<binding name="testBinding" type="tns:testPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="welcome">
<soap:operation soapAction="http://localhost/2018/ServerWelcome.php/welcome" style="rpc"/>
<input>
<soap:body use="encoded" namespace="" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="test">
<port name="testPort" binding="tns:testBinding">
<soap:address location="http://localhost/2018/ServerWelcome.php"/>
</port>
</service>
</definitions>

以及客户端代码:

include('lib/nusoap.php');

try{
    $client = new soapclient('http://localhost/2018/ServerWelcome.php?wsdl');

    $response = $client->welcome('John');

    echo($respone);

} catch(soap_fault $e){
    var_dump($e);
}

我读过很多类似的问题,但是任何答案都可以。我不知道该怎么办...

0 个答案:

没有答案