我正在尝试使用PHP和SOAP运行Web服务,但到目前为止,我所得到的只是:
(SoapFault)[2]消息指出:'SOAP-ERROR:解析WSDL:无法从' http://localhost/MyRegistration/login.xml '加载:无法加载外部实体" http:// localhost/MyRegistration /login.xml "
我已经尝试将localhost更改为127.0.0.1,但这没有任何区别.login实际上是一个wsdl文件,但是如果我把login.wsdl放在SOAPClient构造函数中,它会说"'看起来好像我们没有XML文档'".
这是我的SOAP客户端代码(register_client.php):
<?php
try
{
$sClient = new SoapClient('http://127.0.0.1/MyRegistration/login.wsdl');
$param1 = $_POST["regname"];
$param2 = $_POST["regpass1"];
$response = $sClient->loginVerify($param1, $param2);
var_dump($response);
}
catch(SoapFault $e)
{
var_dump($e);
}
?>
Run Code Online (Sandbox Code Playgroud)
这是login.wsdl文件:
<?xml version="1.0"?>
<definitions name="LoginVal"
targetNamespace="urn:LoginVal"
xmlns:tns="urn:LoginVal"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Login">
<xsd:element name="getName" type="xsd:string" />
<xsd:element name="getPass" type="xsd:string" />
<xsd:element name="LoginResponse" type="xsd:string" />
</xsd:schema>
</types>
<message name="loginVerify">
<part name="username" type="tns:getName" />
<part name="password" type="tns:getPass" />
</message>
<message name="doLoginResponse">
<part name="return" …Run Code Online (Sandbox Code Playgroud)