使用NuSoap 1.94与PHP 5.2.17进行SOAP客户端调用时出现致命错误

时间:2013-08-06 14:33:30

标签: php soap nusoap

在尝试使用NuSoap 1.94和PHP 5.2.17对soapclient进行soapclient调用时,调用基于xBase ++的Web服务器(不使用WSDL)时收到错误消息。这个完全相同的代码适用于PHP 4上的NuSOAP 1.94。任何想法或帮助都将不胜感激!

注意(我必须从下面的错误消息中删除https://部分地址 - 我收到错误信息,说我需要10个声望才能发布2个或更多链接)

谢谢,

撒拉族

  

致命错误:未捕获的SoapFault异常:[WSDL] SOAP-ERROR:解析WSDL:无法从'xxx.xxx.com:55055'加载:无法加载外部实体“xxx.xxx.com:55055” /hsphere/local/home/xxx/xxx.com/phpinvent/inc/functions/xmsg.php:34堆栈跟踪:#0 /hsphere/local/home/xxx/xxx.com/phpinvent/inc/functions/xmsg。 php(34):SoapClient-> SoapClient('https://xxx.xxx ...')#1 /hsphere/local/home/xxx/xxx.com/phpinvent/xmsgtest.php(15):XMsg('LOGIN ',数组)在第34行的/hsphere/local/home/xxx/xxx.com/phpinvent/inc/functions/xmsg.php中抛出#2 {main}

这是我的测试页面的代码和xmsg函数:

<?php
ini_set('display_errors', 'On');
ini_set('default_socket_timeout', 300);
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// include configuration
require_once('inc/config.php');
require_once('inc/nusoap/nusoap.php'); // include the NuSOAP classes

$xmsg_param[0][0] = "userid";
$xmsg_param[0][1] = "TEST";
$xmsg_param[1][0] = "password";
$xmsg_param[1][1] = "TEST";

$result = XMsg("LOGIN", $xmsg_param);
echo("<br>resulttxt: ".$result['xmsg_resulttxt']);
echo("<br>Sessionid: ".$result['sessionid']);

?>

<?php
// XMsg *************************************************************************
// This function is used to send a message through the robust, connectionless message system
function XMsg($xm_type, $xm_parameters, $xm_target = XMSG_DEFAULT_GATEWAY, $xm_mode = XMSG_DEFAULT_MODE)
{
    // Parameters:
    // xm_type - C - mandatory – type of message being sent
    // xm_parameters - A - optional - 2 dimensional array of name/value pairs that will be sent to the target with the message
    // xm_target - C - optional - target - currently supports only URLs of AutoMate agents - defaults to gateway
    // xm_mode - C - optional - tokens that allow for modification of the message - currently defaults to #SOAP# to send via SOAP
    // Returns:
    // xm_result - A - array of name/value pairs returned from the target in same format as xm_target
    $xm_SOAPagent   = '';       // SOAP Envelope Object - Request
    $xm_SOAPresult  = '';       // SOAP Envelope Object - Response
    $xm_SOAPclass   = '';
    $xm_retrynum    = 0;        // Number of retries attempted
    $xm_retry       = true;     // Continue retrying?
    $xm_result      = Array();  // Array of results returned by XMsg
    $xm_numparams   = 0;        // Number of parameters passed to XMsg
    $xm_I           = 0;        // FOR Loop Counter
    // Initialize Parameters
    $xm_parameters  = (gettype($xm_parameters) == "array" ? $xm_parameters : array());

    // check if mandatory parameters are passed
    // xm_type must be character and not empty
    if (gettype($xm_type)=="string" && !empty($xm_type)) {
       switch($xm_mode)
       {
          case "SOAP":
              // open SOAP envelope and initialize
              echo("calling xm_target: ".$xm_target."<br>");
              $soapclient = new soapclient($xm_target);

              $soapparam = array();

              // create and pass xmsg structure - NOTE: this section is specialized to PHP
              $soapparam['xmsg_id'] = '';
              $soapparam['xmsg_source'] = '';
              $soapparam['xmsg_target'] = $xm_target;
              $soapparam['xmsg_session'] = $_SESSION['SESSIONID'];
              $soapparam['xmsg_userid'] = $_SESSION['USERID'];
              $soapparam['xmsg_websessid'] = session_id();
              $soapparam['xmsg_ip'] = $_SERVER['REMOTE_ADDR'];
              $soapparam['xmsg_status'] = 'SENT';
              $soapparam['xmsg_type'] = $xm_type;
              $soapparam['xmsg_result'] = '';
              $soapparam['xmsg_resulttxt'] = '';
              $soapparam['xmsg_date'] = date("m/d/y");
              $soapparam['xmsg_time'] = date("H:i:s");
              $soapparam['xmsg_datereceive'] = '';
              $soapparam['xmsg_timereceive'] = '';
              $soapparam['xmsg_dateresponse'] = '';
              $soapparam['xmsg_timeresponse'] = '';

              // count parameters and add to SOAP Envelope
              $xm_numparams = count($xm_parameters);
              for ($xm_I = 0; $xm_I < $xm_numparams; $xm_I++) {
                  echo("setting soapparam[".$xm_parameters[$xm_I][0]."] to :".$xm_parameters[$xm_I][1]);
                  $soapparam[$xm_parameters[$xm_I][0]] = $xm_parameters[$xm_I][1];
              }

              // SOAP retry loop start - retry until xm_retry is false - set to false when call succeeds or max # retries exceeded
              do {

                 // run remote SOAP call for RemoteCall as specified in
                 $xm_result = $soapclient->call('XMsg',$soapparam);
                 // check for fault
                 echo ("Fault: ".$xm_result['FAULT']."<br>");
                 echo ("1 Faultcode: ".$xm_result['faultcode']."<br>");
                 if (empty($xm_result['faultcode'])) {
                     echo('<hr>'.'<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>');
                     echo('<hr>'.'<pre>' . htmlspecialchars($soapclient->debug_str, ENT_QUOTES) . '</pre>');
                    $xm_retry  = false;
                    // update status / response date / time
                    $xm_result['xmsg_status'] = "RECEIVED";
                    $xm_result['xmsg_dateresponse'] = date("m/d/y");
                    $xm_result['xmsg_timeresponse'] = date("H:i:s");
                 } else {
                     echo("2 faultcode: ".$xm_result['faultcode']);
                 }
                 // SOAP Call retry handling
                 if ($xm_retry) {
                    // increase the SOAP comm retry counter to count the number of retries made
                    $xm_retrynum++;
                    // check if the maximum number of retries has been reached
                    if ($xm_retrynum <= XMSG_NUMRETRY) {
                       sleep(XMSG_RETRYDELAY); // delay for set number of seconds
                    } else {
                       $xm_retry = false;
                    }
                 }
              } while ($xm_retry);
            break;
        default:
          // no other message type handling currently
        }
    }
}

return $xm_result;
// XMsg *************************************************************************

1 个答案:

答案 0 :(得分:0)

这很简单。您的Web服务器无法查看WSDL所在的位置。如果您复制WSDL网址并将其粘贴到浏览器中,您是否可以访问该位置?您应该检查您使用的URL是否正确,以及您的Web服务器是否甚至可以看到该位置。如果不是,你需要在它起作用之前补救它。