我正试图在PHP和web服务的帮助下构建一个web应用程序。我想通过web服务使用PHP的PDO连接到数据库。我已经构建了服务器文件、客户端文件和wsdl文件。通过各种测试,我发现我的wsdl文件存在一些问题,因为当我在服务器和客户端文件中使用其他wsdl文件运行其他函数时,它们可以正常工作。我在localhost上工作,所有文件都位于wamp/www/myApp/目录(Apache 2.2.8,PHP 5.2.6)中。我发布wsdl文件供您参考。请告诉我哪里出错了,并指导我纠正错误。谢谢
wsdl文件:
<?xml version="1.0" encoding="utf-8"?>
<definitions name="MyService" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://My.Local.IP/myApp/api/my.wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<message name="LoginRequest">
<part name="dns" type="xsd:string"/>
<part name="user" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="LoginResponse">
<part name="result" type="xsd:string"/>
</message>
<portType name="Fetch_PortType">
<operation name="Login">
<input message="tns:LoginRequest"/>
<output message="tns:LoginResponse"/>
</operation>
</portType>
<binding name="MyService_Binding" type="tns:Fetch_PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Login">
<soap:operation soapAction="http://My.Local.IP/myApp/api/Login"/>
<input name="Login">
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</input>
<output name="Login">
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"/>
</output>
</operation>
</binding>
<service name="My_Service">
<documentation>WSDL File MyService</documentation>
<port name="Fetch_PortType" binding="tns:MyService_Binding">
<soap:address location="http://My.Local.IP/myApp/api/server.php"/>
</port>
</service>
</definitions>
可能是服务器类或实现Login方法的类/函数中的PHP错误。当您直接访问该文件时会发生什么?请检查您的错误日志。
我自己从来没有写过WSDL。相反,您可以编写一个镜像.NETWeb服务,并使用自动生成的WSDL(由MSVisualStudio生成)。