无法使用php连接到SOAP Web服务(WSDL)

时间:2015-01-30 19:07:30

标签: authentication soap wsdl

我有一个用户名和密码,但是在使用身份验证时尝试通过WSDL向SOAP Web服务器发送请求时,它会显示错误未指定用户名。

我做错了什么?提前致谢

<?php
require_once('lib/nusoap.php');
$username = 'user';
$password = 'pass';

$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';
//echo 'You must set your username and password in the source';
//exit();
$client = new nusoap_client("example.com:88/Service.asmx?wsdl", 'wsdl',
      $proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
 echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$client->setUseCurl($useCURL);
$client->loadWSDL();
$client->setCredentials($username, $password, 'digest');
$result = $client->call('GetValidTourList', array());

if ($client->fault) {
 echo '<h2>Fault</h2><pre>';
 print_r($result);
 echo '</pre>';
} else {
 $err = $client->getError();
 if ($err) {
  echo '<h2>Error</h2><pre>' . $err . '</pre>';
 } else {
  echo '<h2>Result</h2><pre>';
  print_r($result);
  echo '</pre>';
 }
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>

0 个答案:

没有答案