使用Codeigniter解析错误NuSOAP webservice

时间:2014-05-19 20:26:52

标签: codeigniter soap nusoap

我将CodeIgniter和NuSOAP库用于webservices,这是我访问Client控制器时遇到的错误:

wsdl error: XML error parsing WSDL from http://localhost/turismoadmin/index.php/Webservice/index/wsdl on line 77: Attribute without value

这是服务器控制器:

class Webservice extends CI_Controller {

function __construct(){
    parent::__construct();
    $this->load->library('soap_lib');

    $server = new nusoap_server;
    $server->configureWSDL('Agencia Turistica', 'urn:server');
    $server->wsdl->schemaTargetNamespace = 'urn:server';

    $server->register('addcontact',
        array('nombre' => 'xsd:string', 'apellido' => 'xsd:string' , 'ciudad' => 'xsd:string'),
        array('return' => 'xsd:string'));

    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA: '';
    $server->service($HTTP_RAW_POST_DATA);
}

function index()
{
    if($this->uri->rsegment(3)=="wsdl"){
        $_SERVER['QUERY_STRING']="wsdl";
    }else{
        $_SERVER['QUERY_STRING']="";
    }

    function addcontact($nombre, $apellido, $ciudad){
        $this->modelo_turismo->addcontact($nombre, $apellido, $ciudad);
        $resultado = $this->modelo_turismo->selectmax_contacto();
        return (json_encode($resultado->fetch_all()));
    }

}

}

这是客户端控制器:

class Client extends CI_controller {

function __construct() {
    parent::__construct();
}

function index() {

    $this->load->library('soap_lib');
    $this->nusoap_client = new nusoap_client(site_url('Webservice/index/wsdl'), true);
    $err = $this->nusoap_client->getError();
    if ($err){
        echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    }
    $result1 = $this->nusoap_client->call('addcontact', array("marcos","de lafuente","hermosillo"));
    echo($result1);


    // Check for a fault
    if ($this->nusoap_client->fault) {
        echo '<h2>Fault</h2><pre>';
        print_r($result1);
        echo '</pre>';
    } else {
        // Check for errors
        $err = $this->nusoap_client->getError();
        if ($err) {
            // Display the error
            echo '<h2>Error</h2><pre>' . $err . '</pre>';
        } else {
            // Display the result
            echo '<h2>Result</h2><pre>';
            print_r($result1);
        echo '</pre>';
        }
    }
}

}

我试图以此为基础 ON THIS TOPIC(非常感谢nana.chorage)

我还将此条目添加到我的config / routes.php

$route['Webservice/wsdl']="Webservice/index/wsdl";

为了不被忽视,我输入此网址时可以看到我的服务:

http://localhost/turismoadmin/index.php/Webservice/wsdl

我真的不知道我做错了什么,我已经搜索了很多,我无法摆脱它!

1 个答案:

答案 0 :(得分:1)

然后nusoap客户端URL应该是这样的

$this->nusoap_client = new nusoap_client(site_url('Webservice/index?wsdl'), 'wsdl');