我正在测试Ilias Soap界面。我的登录功能有问题。
<?php
include_once ("./nusoap/nusoap.php");
$client = new nusoap_client("https://localhost/ilias/webservice/soap/server.php?wsdl");
$client->soap_defencoding = 'UTF-8'; //that is a not working solution from stackoverflow
if ($err = $client->getError())
{
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$valid = $client->call('login',
array('client' => "ILIAS",
'password' => "pw",
'username' => "root"));
if ($err = $client->getError())
{
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
print_r($client);
?>
我收到此错误:
构造函数错误 SOAP-ERROR:解析WSDL:无法从“http://localhost/ilias/webservice/soap/nusoapserver.php?wsdl”加载:文档末尾的额外内容
这是印刷品:
nusoap_client Object (
[username] =>
[password] =>
[authtype] =>
[certRequest] => Array ( )
[requestHeaders] =>
[responseHeaders] =>
[responseHeader] =>
[document] => WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl"
[endpoint] => https://localhost/ilias/webservice/soap/server.php?wsdl
[forceEndpoint] =>
[proxyhost] =>
[proxyport] =>
[proxyusername] =>
[proxypassword] =>
[portName] =>
[xml_encoding] => UTF-8
[http_encoding] =>
[timeout] => 0
[response_timeout] => 30
[endpointType] => soap
[persistentConnection] =>
[defaultRpcParams] =>
[request] => POST /ilias/webservice/soap/server.php?wsdl HTTP/1.0 Host: localhost User-Agent: NuSOAP/0.9.5 (1.123) Content-Type: text/xml; charset=UTF-8 SOAPAction: "" Content-Length: 591 ILIASpwroot
[response] => HTTP/1.1 500 Internal Service Error Date: Thu, 20 Jul 2017 07:33:55 GMT Server: Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/5.6.31 X-Powered-By: PHP/5.6.31 Content-Length: 462 Connection: close Content-Type: text/xml; charset=utf-8 WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl"
[responseData] => WSDLSOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl"
[cookies] => Array ( )
[decode_utf8] => 1
[operations] => Array ( )
[curl_options] => Array ( )
[bindingType] => [use_curl] =>
[fault] => 1
[faultcode] => WSDL [faultstring] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl"
[faultdetail] =>
[title] => NuSOAP
[version] => 0.9.5
[revision] => $Revision: 1.123 $
[error_str] => WSDL: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl"
[debug_str] => 2017-07-20 09:33:55.728354 nusoap_client: ctor wsdl= timeout=0 response_timeout=30 endpoint=string(55) "https://localhost/ilias/webservice/soap/server.php?wsdl" 2017-07-20 09:33:55.728407 nusoap_client: instantiate SOAP with endpoint at https://localhost/ilias/webservice/soap/server.php?wsdl 2017-07-20 09:33:55.728430 nusoap_client: call: operation=login, namespace=http://tempuri.org, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=soap params=array(3) { ["client"]=> string(5) "ILIAS" ["password"]=> string(2) "pw" ["username"]=> string(4) "root" } headers=bool(false) 2017-07-20 09:33:55.728456 nusoap_client: serializing param array for operation login 2017-07-20 09:33:55.728467 nusoap_client: in serialize_val: name=client, type=, name_ns=, type_ns=, use=encoded, soapval= value=string(5) "ILIAS" attributes=bool(false) 2017-07-20 09:33:55.728484 nusoap_client: serialize_val: serialize string 2017-07-20 09:33:55.728498 nusoap_client: serialize_val returning ILIAS 2017-07-20 09:33:55.728507 nusoap_client: in serialize_val: name=password, type=, name_ns=, type_ns=, use=encoded, soapval= value=string(2) "pw" attributes=bool(false) 2017-07-20 09:33:55.728518 nusoap_client: serialize_val: serialize string 2017-07-20 09:33:55.728528 nusoap_client: serialize_val returning pw 2017-07-20 09:33:55.728536 nusoap_client: in serialize_val: name=username, type=, name_ns=, type_ns=, use=encoded, soapval= value=string(4) "root" attributes=bool(false) 2017-07-20 09:33:55.728546 nusoap_client: serialize_val: serialize string 2017-07-20 09:33:55.728555 nusoap_client: serialize_val returning root 2017-07-20 09:33:55.728563 nusoap_client: wrapping RPC request with encoded method element 2017-07-20 09:33:55.728574 nusoap_client: In serializeEnvelope length=199 body (max 1000 characters)=ILIASpwroot style=rpc use=encoded encodingStyle=http://schemas.xmlsoap.org/soap/encoding/ 2017-07-20 09:33:55.728583 nusoap_client: headers: bool(false) 2017-07-20 09:33:55.728590 nusoap_client: namespaces: array(0) { } 2017-07-20 09:33:55.728607 nusoap_client: endpoint=https://localhost/ilias/webservice/soap/server.php?wsdl, soapAction=, namespace=http://tempuri.org, style=rpc, use=encoded, encodingStyle=http://schemas.xmlsoap.org/soap/encoding/ 2017-07-20 09:33:55.728614 nusoap_client: SOAP message length=591 contents (max 1000 bytes)=ILIASpwroot 2017-07-20 09:33:55.728633 nusoap_client: transporting via HTTP 2017-07-20 09:33:55.728745 nusoap_client: sending message, length=591 2017-07-20 09:33:55.728648 soap_transport_http: ctor url=https://localhost/ilias/webservice/soap/server.php?wsdl use_curl= curl_options: array(0) { } 2017-07-20 09:33:55.728665 soap_transport_http: parsed URL scheme = https 2017-07-20 09:33:55.728673 soap_transport_http: parsed URL host = localhost 2017-07-20 09:33:55.728679 soap_transport_http: parsed URL path = /ilias/webservice/soap/server.php 2017-07-20 09:33:55.728685 soap_transport_http: parsed URL query = wsdl 2017-07-20 09:33:55.728703 soap_transport_http: set header Host: localhost 2017-07-20 09:33:55.728720 soap_transport_http: set header User-Agent: NuSOAP/0.9.5 (1.123) 2017-07-20 09:33:55.728729 soap_transport_http: set header Content-Type: text/xml; charset=UTF-8 2017-07-20 09:33:55.728737 soap_transport_http: set header SOAPAction: "" 2017-07-20 09:33:55.728758 soap_transport_http: entered send() with data of length: 591 2017-07-20 09:33:55.728769 soap_transport_http: connect connection_timeout 0, response_timeout 30, scheme https, host localhost, port 443 2017-07-20 09:33:55.728782 soap_transport_http: connect using cURL 2017-07-20 09:33:55.728817 soap_transport_http: setCurlOption option=10002, value= string(59) "https://localhost:443/ilias/webservice/soap/server.php?wsdl" 2017-07-20 09:33:55.728833 soap_transport_http: setCurlOption option=52, value= int(1) 2017-07-20 09:33:55.728842 soap_transport_http: setCurlOption option=42, value= int(1) 2017-07-20 09:33:55.728851 soap_transport_http: setCurlOption option=19913, value= int(1) 2017-07-20 09:33:55.728859 soap_transport_http: setCurlOption option=13, value= int(30) 2017-07-20 09:33:55.728868 soap_transport_http: set cURL SSL verify options 2017-07-20 09:33:55.728874 soap_transport_http: setCurlOption option=64, value= int(0) 2017-07-20 09:33:55.728883 soap_transport_http: setCurlOption option=81, value= int(0) 2017-07-20 09:33:55.728892 soap_transport_http: cURL connection set up 2017-07-20 09:33:55.728903 soap_transport_http: set header Content-Length: 591 2017-07-20 09:33:55.728910 soap_transport_http: HTTP request: POST /ilias/webservice/soap/server.php?wsdl HTTP/1.0 2017-07-20 09:33:55.728918 soap_transport_http: HTTP header: Host: localhost 2017-07-20 09:33:55.728925 soap_transport_http: HTTP header: User-Agent: NuSOAP/0.9.5 (1.123) 2017-07-20 09:33:55.728931 soap_transport_http: HTTP header: Content-Type: text/xml; charset=UTF-8 2017-07-20 09:33:55.728938 soap_transport_http: HTTP header: SOAPAction: "" 2017-07-20 09:33:55.728946 soap_transport_http: HTTP header: Content-Length: 591 2017-07-20 09:33:55.728957 soap_transport_http: Skip cURL header Host: localhost 2017-07-20 09:33:55.728966 soap_transport_http: Skip cURL header Content-Length: 591 2017-07-20 09:33:55.728972 soap_transport_http: setCurlOption option=10023, value= array(3) { [0]=> string(32) "User-Agent: NuSOAP/0.9.5 (1.123)" [1]=> string(37) "Content-Type: text/xml; charset=UTF-8" [2]=> string(14) "SOAPAction: """ } 2017-07-20 09:33:55.728985 soap_transport_http: set cURL HTTP headers 2017-07-20 09:33:55.728992 soap_transport_http: setCurlOption option=47, value= int(1) 2017-07-20 09:33:55.729001 soap_transport_http: setCurlOption option=10015, value= string(591) "ILIASpwroot" 2017-07-20 09:33:55.729012 soap_transport_http: set cURL POST data 2017-07-20 09:33:55.729019 soap_transport_http: set cURL payload 2017-07-20 09:33:55.729028 soap_transport_http: send and receive with cURL 2017-07-20 09:33:55.774636 soap_transport_http: No cURL error, closing cURL 2017-07-20 09:33:55.774734 soap_transport_http: found proper separation of headers and document 2017-07-20 09:33:55.774754 soap_transport_http: cleaned data, stringlen: 462 2017-07-20 09:33:55.774797 soap_transport_http: No Content-Encoding header 2017-07-20 09:33:55.774811 soap_transport_http: end of send() 2017-07-20 09:33:55.774846 nusoap_client: got response, length=462 type=text/xml; charset=utf-8 2017-07-20 09:33:55.774863 nusoap_client: Entering parseResponse() for data of length 462 headers: array(6) { ["date"]=> string(29) "Thu, 20 Jul 2017 07:33:55 GMT" ["server"]=> string(47) "Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/5.6.31" ["x-powered-by"]=> string(10) "PHP/5.6.31" ["content-length"]=> string(3) "462" ["connection"]=> string(5) "close" ["content-type"]=> string(23) "text/xml; charset=utf-8" } 2017-07-20 09:33:55.774900 nusoap_client: Got response encoding: utf-8 2017-07-20 09:33:55.774922 nusoap_client: Use encoding: UTF-8 when creating nusoap_parser 2017-07-20 09:33:55.774962 nusoap_parser: Charset from HTTP Content-Type matches encoding from XML declaration 2017-07-20 09:33:55.774978 nusoap_parser: Entering nusoap_parser(), length=462, encoding=UTF-8 2017-07-20 09:33:55.775096 nusoap_parser: found root struct Fault, pos 2 2017-07-20 09:33:55.775182 nusoap_parser: in buildVal() for Fault(pos 2) of type struct 2017-07-20 09:33:55.775196 nusoap_parser: in buildVal, there are children 2017-07-20 09:33:55.775218 nusoap_parser: in buildVal, adding Java Vector or generic compound type Fault 2017-07-20 09:33:55.775246 nusoap_parser: in buildVal, return: array(2) { ["faultcode"]=> &string(4) "WSDL" ["faultstring"]=> &string(206) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl" " } 2017-07-20 09:33:55.775288 nusoap_parser: in nusoap_parser ctor, message: array(5) { [0]=> array(9) { ["pos"]=> int(0) ["children"]=> string(2) "|1" ["cdata"]=> string(0) "" ["depth"]=> int(0) ["parent"]=> string(0) "" ["status"]=> string(8) "envelope" ["name"]=> string(8) "Envelope" ["attrs"]=> array(1) { ["xmlns:SOAP-ENV"]=> string(41) "http://schemas.xmlsoap.org/soap/envelope/" } ["namespace"]=> string(41) "http://schemas.xmlsoap.org/soap/envelope/" } [1]=> array(9) { ["pos"]=> int(1) ["children"]=> string(2) "|2" ["cdata"]=> string(0) "" ["depth"]=> int(1) ["parent"]=> int(0) ["status"]=> string(4) "body" ["name"]=> string(4) "Body" ["attrs"]=> array(0) { } ["namespace"]=> string(41) "http://schemas.xmlsoap.org/soap/envelope/" } [2]=> array(11) { ["pos"]=> int(2) ["children"]=> string(4) "|3|4" ["cdata"]=> string(0) "" ["depth"]=> int(2) ["parent"]=> int(1) ["type"]=> string(6) "struct" ["status"]=> string(6) "method" ["name"]=> string(5) "Fault" ["attrs"]=> array(0) { } ["namespace"]=> string(41) "http://schemas.xmlsoap.org/soap/envelope/" ["result"]=> array(2) { ["faultcode"]=> &string(4) "WSDL" ["faultstring"]=> &string(206) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl" " } } [3]=> array(10) { ["pos"]=> int(3) ["children"]=> string(0) "" ["cdata"]=> string(4) "WSDL" ["depth"]=> int(3) ["parent"]=> int(2) ["status"]=> string(6) "method" ["name"]=> string(9) "faultcode" ["attrs"]=> array(0) { } ["namespace"]=> string(41) "http://schemas.xmlsoap.org/soap/envelope/" ["result"]=> &string(4) "WSDL" } [4]=> array(10) { ["pos"]=> int(4) ["children"]=> string(0) "" ["cdata"]=> string(206) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl" " ["depth"]=> int(3) ["parent"]=> int(2) ["status"]=> string(6) "method" ["name"]=> string(11) "faultstring" ["attrs"]=> array(0) { } ["namespace"]=> string(41) "http://schemas.xmlsoap.org/soap/envelope/" ["result"]=> &string(206) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl" " } } 2017-07-20 09:33:55.775361 nusoap_parser: parsed successfully, found root struct: 2 of name Fault 2017-07-20 09:33:55.775413 nusoap_client: sent message successfully and got a(n) array return=array(2) { ["faultcode"]=> string(4) "WSDL" ["faultstring"]=> string(206) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl" " } 2017-07-20 09:33:55.775437 nusoap_client: got fault 2017-07-20 09:33:55.775452 nusoap_client: faultcode = WSDL
2017-07-20 09:33:55.775463 nusoap_client: faultstring = SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl"
[charencoding] => 1
[debugLevel] => 9
[XMLSchemaVersion] => http://www.w3.org/2001/XMLSchema
[soap_defencoding] => UTF-8
[namespaces] => Array (
[SOAP-ENV] => http://schemas.xmlsoap.org/soap/envelope/ [xsd] => http://www.w3.org/2001/XMLSchema
[xsi] => http://www.w3.org/2001/XMLSchema-instance [SOAP-ENC] => http://schemas.xmlsoap.org/soap/encoding/ )
[usedNamespaces] => Array ( )
[typemap] => Array ( [http://www.w3.org/2001/XMLSchema] => Array (
[string] => string
[boolean] => boolean
[float] => double
[double] => double
[decimal] => double
[duration] =>
[dateTime] => string
[time] => string
[date] => string
[gYearMonth] =>
[gYear] =>
[gMonthDay] =>
[gDay] =>
[gMonth] =>
[hexBinary] => string
[base64Binary] => string
[anyType] => string
[anySimpleType] => string
[normalizedString] => string
[token] => string
[language] =>
[NMTOKEN] =>
[NMTOKENS] =>
[Name] =>
[NCName] =>
[ID] =>
[IDREF] =>
[IDREFS] =>
[ENTITY] =>
[ENTITIES] =>
[integer] => integer
[nonPositiveInteger] => integer
[negativeInteger] => integer
[long] => integer
[int] => integer
[short] => integer
[byte] => integer
[nonNegativeInteger] => integer
[unsignedLong] =>
[unsignedInt] =>
[unsignedShort] =>
[unsignedByte] =>
[positiveInteger] =>
)
[http://www.w3.org/2000/10/XMLSchema] => Array (
[i4] =>
[int] => integer
[boolean] => boolean
[string] => string
[double] => double
[float] => double
[dateTime] => string
[timeInstant] => string
[base64Binary] => string
[base64] => string
[ur-type] => array
)
[http://www.w3.org/1999/XMLSchema] => Array (
[i4] =>
[int] => integer
[boolean] => boolean
[string] => string
[double] => double
[float] => double
[dateTime] => string
[timeInstant] => string
[base64Binary] => string
[base64] => string
[ur-type] => array
)
[http://soapinterop.org/xsd] => Array (
[SOAPStruct] => struct
)
[http://schemas.xmlsoap.org/soap/encoding/] => Array ( [base64] => string [array] => array [Array] => array )
[http://xml.apache.org/xml-soap] => Array ( [0] => Map ) )
[xmlEntities] => Array (
[quot] => "
[amp] => &
[lt] => <
[gt] => >
[apos] => '
)
[operation] => login
[opData] => Array ( )
[return] => Array (
[faultcode] => WSDL
[faultstring] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl' : failed to load external entity "https://localhost/ilias/webservice/soap/nusoapserver.php?wsdl"
)
)
有什么想法吗?
答案 0 :(得分:0)
加载https://localhost/ilias/webservice/soap/server.php?wsdl并将结果保存在某个文件中。然后使用一些XML验证程序(例如https://www.xmlvalidation.com/)并检查文档是否有效。
您描述的问题通常发生在生成WSDL的PHP代码中将输出写入文件的情况下,例如PHP错误消息。肉眼在文件中可能已经可见。
然后采取适当的措施来清理输出并获得正确的WSDL。
答案 1 :(得分:0)
在这里您可以尝试下面的代码,它在带有nusoap-0.9.5库的ILIAS 5.3.8上对我有效,iirc项目中的一个对我也不起作用。
require_once("./nusoap-0.9.5/lib/nusoap.php");
$wsdlUrl = "http://yourilias/webservice/soap/server.php?wsdl";
$soapClient = new nusoap_client($wsdlUrl, true);
$login["client"] = 'client1';
$login["username"] = "root";
$login["password"] = "rootPass";
$sessionId = $soapClient->call("login", $login); // call other soap requests using the sessiondId/sid
echo var_dump(lookupUser("John Doe"));
function lookupUser($login)
{
global $soapClient, $sessionId;
$user = $soapClient->call("lookupUser", array($sessionId, $login));
if ($user != 0) {
return $user;
}
return 0;
}