我必须使用web服务,创建它的程序员给了我端点以及wsdl的链接。
如何创建客户端?使用wsdl链接还是端点?
当我尝试连接时,我有以下返回
"Warning: SoapClient::SoapClient(http://mv114.agraria.coop.br:50000/XISOAPAdapter/MessageServlet?channel=:BC_SOAP_CV:CC_SOAP_CV_Sender) [function.SoapClient-SoapClient]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in /srv/www/htdocs/wwwintranet/nusoap_ex/sap_xml.php on line 6 Warning: SoapClient::SoapClient() [function.SoapClient-SoapClient]: I/O warning : failed to load external entity "http://mv114.agraria.coop.br:50000/XISOAPAdapter/MessageServlet?channel=:BC_SOAP_CV:CC_SOAP_CV_Sender" in /srv/www/htdocs/wwwintranet/nusoap_ex/sap_xml.php on line 6 Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://mv114.agraria.coop.br:50000/XISOAPAdapter/MessageServlet?channel=:BC_SOAP_CV:CC_SOAP_CV_Sender' in /srv/www/htdocs/wwwintranet/nusoap_ex/sap_xml.php:6 Stack trace: #0 /srv/www/htdocs/wwwintranet/nusoap_ex/sap_xml.php(6): SoapClient->SoapClient('http://mv114.ag...') #1 {main} thrown in /srv/www/htdocs/wwwintranet/nusoap_ex/sap_xml.php on line 6"
代码:
require_once('nusoap.php');
$client = new SoapClient('http://mv114.agraria.coop.br:50000/XISOAPAdapter/MessageServlet?channel=:BC_SOAP_CV:CC_SOAP_CV_Sender');
//$client = new SoapClient('http: //mv114.agraria.coop.br:50000/dir/wsdl?p=ic/55b6a9155f353207b6e7c92f548bbb98');
$client->setHTTPProxy("http: //wmv114.agraria.coop.br",50000,"WSPO","WAgr9876");
$err = $client->getError();
if ($err){
echo "Error". $err.;
}
else
{
echo "OK!!";
}
答案 0 :(得分:0)
new SoapClient
中的第一个参数需要一个WSDL,你不会给它一个WSDL。
将其更改为WSDL或在第二个参数中给出位置/ uri:
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));