只有"hello"函数在我的 WSDL 中工作



在我的Symfony服务器上设置一个Web服务,我遵循以下指南: https://symfony.com/doc/current/controller/soap_web_service.html 给出的示例运行良好,带有以下 hello fonction:

public function hello($name)
{
return 'Hello, '.$name;
}

所以我尝试用这个 bye 函数完成这个网络服务:

public function bye($name)
{
return 'Goodbye, '.$name;
}

这是我的 wsdl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<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="urn:arnleadservicewsdl"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="urn:helloservicewsdl">
<types>
<xsd:schema targetNamespace="urn:hellowsdl">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
</xsd:schema>
</types>
<message name="helloRequest">
<part name="name" type="xsd:string" />
</message>
<message name="helloResponse">
<part name="return" type="xsd:string" />
</message>
<message name="byeRequest">
<part name="name" type="xsd:string" />
</message>
<message name="byeResponse">
<part name="return" type="xsd:string" />
</message>
<portType name="hellowsdlPortType">
<operation name="hello">
<documentation>Hello World</documentation>
<input message="tns:helloRequest"/>
<output message="tns:helloResponse"/>
</operation>
<operation name="bye">
<documentation>Goodbye World</documentation>
<input message="tns:byeRequest"/>
<output message="tns:byeResponse"/>
</operation>
</portType>
<binding name="hellowsdlBinding" type="tns:hellowsdlPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="hello">
<soap:operation soapAction="urn:arnleadservicewsdl#hello" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:hellowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:hellowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="bye">
<soap:operation soapAction="urn:arnleadservicewsdl#bye" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:hellowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:hellowsdl"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="hellowsdl">
<port name="hellowsdlPort" binding="tns:hellowsdlBinding">
<soap:address location="http://10.0.0.42/esi/soap" />
</port>
</service>
</definitions>

Hello函数仍在工作,但是每次调用bye函数时,都会收到一个错误:

致命错误:未捕获的 SoapFault 异常:[客户端] 看起来我们没有 XML

我错在哪里?

好的,首先我在 https://www.wsdl-analyzer.com/的帮助下重写了我的 WSDL。这是我的新 WSDL:

<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions name="helloServiceController"
targetNamespace="urn:helloServiceControllerwsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:helloServiceControllerwsdl">
<wsdl:types>
<xsd:schema targetNamespace="urn:helloServiceControllerwsdl">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="helloRequest">
<wsdl:part name="name" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="helloResponse">
<wsdl:part name="return" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="byeRequest">
<wsdl:part name="name" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="byeResponse">
<wsdl:part name="return" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="helloServicePortType">
<wsdl:operation name="hello">
<wsdl:documentation>Hello World</wsdl:documentation>
<wsdl:input message="tns:helloRequest"/>
<wsdl:output message="tns:helloResponse"/>
</wsdl:operation>
<wsdl:operation name="bye">
<wsdl:documentation>Bye World</wsdl:documentation>
<wsdl:input message="tns:byeRequest"/>
<wsdl:output message="tns:byeResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="helloServiceBinding" type="tns:helloServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="hello">
<soap:operation soapAction="urn:helloServiceControllerwsdl#hello" style="rpc"/>
<wsdl:input>
<soap:body use="encoded" namespace="urn:helloServiceControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="urn:helloServiceControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="bye">
<soap:operation soapAction="urn:helloServiceControllerwsdl#bye" style="rpc"/>
<wsdl:input>
<soap:body use="encoded" namespace="urn:helloServiceControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="urn:helloServiceControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="helloService">
<wsdl:port name="helloServicePort" binding="tns:helloServiceBinding">
<soap:address location="http://10.0.0.42/esi/soap"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

在那之后,它仍然无法正常工作,甚至 hello 功能也不起作用。拉扯头发一段时间后,我只是重新启动了服务器,这很好。可能是缓存问题!

最新更新