【问题标题】:Codeigniter SOAP Server Error - Reserved XML - already tried trimCodeigniter SOAP 服务器错误 - 保留的 XML - 已尝试修剪
【发布时间】:2016-02-09 01:12:41
【问题描述】:

我正在开发这个需要维护其 SOAP 服务的遗留系统,我目前正在尝试将它与 codeigniter 集成,一直给我一个错误XML error parsing SOAP payload on line 70: Reserved XML Name。 我尝试了有人提到的修剪解决方案,但没有奏效。普通数组不会给我这个错误。只有多维数组。任何建议都会被批准

<?php
class Employee_Trainings_Soap extends MY_Controller {
   public function __construct() {
       parent::__construct();
       $this->load->library("Soap_lib");
       $this->nusoap_server = new soap_server(); 
   }

   public function employee_detail() {   
       $namespace = 'http://localhost/employee_trainings_soap/employee_detail?wsdl';

       $this->nusoap_server->debug_flag = true;
       $this->nusoap_server->configureWSDL('EmployeeTrainings', $namespace);
       $this->nusoap_server->wsdl->schemaTargetNamespace = $namespace;

       $this->nusoap_server->wsdl->addComplexType('response', 'complexType', 'struct', 'all', '', array(
           "validOPIN" => array(
               "name" => "valid_OPIN",
               "type" => "xsd:string"
           ),
           "message" => array(
               "name" => "message",
               "type" => "xsd:string"
           )
       ));

       $this->nusoap_server->wsdl->addComplexType('responses', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array(
           array(
               "ref" => "SOAP-ENC:arrayType",
               "wsdl:arrayType" => "tns:response[]"
           )),
           "tns:response"
       ); 

       $this->nusoap_server->register('getEmployeeTrainings', array("id" => "xsd:string"), array('test'=>'tns:responses'),
           $namespace, $namespace."#getEmployeeTrainings", "rpc", "encoded",
           'Use this service to list notaries connected to the signed-in title company.'
       );

       function getEmployeeTrainings($id) {
           $data = array();
           $data[] =  array('valid_OPIN'=>'test','message'=>'test2');
           $data[] =  array('valid_OPIN'=>'test','message'=>'test2');
           //$data = array('valid_OPIN'=>'test','message'=>'test2');

           return array('test'=>$data);
       }

       $POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
       $this->nusoap_server->service($POST_DATA);
   }   

   function live_client_test() {
       $this->soapclient = new nusoap_client('http://localhost/employee_trainings_soap/employee_detail');

       $err = $this->soapclient->getError();
       if ($err) {
           echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
       }

       $result = $this->soapclient->call('getEmployeeTrainings', array('id' => 'test'));

       if ($this->soapclient->fault) {
           echo '<h2>Fault</h2><pre>';
           print_r($result);
           echo '</pre>';
       } else {
           $err = $this->soapclient->getError();
           if ($err) {                
               echo '<h2>Error</h2><pre>' . $err . '</pre>';
           } else {
               // Display the result
               echo '<h2>Result</h2><pre>';
               print_r($result);
               echo '</pre>';
           }
       }
   }
}

【问题讨论】:

    标签: php xml codeigniter soap


    【解决方案1】:

    所以我发现了问题,这可能不是唯一的解决方案,而是我们发现对我们有用的解决方案。我们必须将 SOAP 服务从 Code Igniter 中取出才能工作。我们在 Code Igniter 之外提供服务的那一刻,它就起作用了。这可能是代码点火器的错误,也可能与我们使用它的方式有关,但作为一种快速解决方案,它起作用了。此外,我们还发现,与 XAMPP 开发盒相比,它在 Linux 开发盒上的效果更好。我希望这对可能遇到相同问题的其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 2015-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      相关资源
      最近更新 更多