codeigniter nusoap客户端错误:wsdl错误:解析WSDL不匹配标记的XML错误

时间:2016-01-28 10:30:00

标签: php codeigniter server client nusoap

这是我的控制器。

Properties prop = new Properties();
InputStream input = null;

try {

      input = getClass().getClassLoader().getResourceAsStream("config.properties");


    // load a properties file
    prop.load(input);

    // get the property value and print it out
    System.out.println(prop.getProperty("database"));
    System.out.println(prop.getProperty("dbuser"));
    System.out.println(prop.getProperty("dbpassword"));

} catch (IOException ex) {
    ex.printStackTrace();
} finally {
    if (input != null) {
        try {
            input.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

控制器位于 controller / cteam / 文件夹中。 这是我的路由器:

    class Cteam extends MY_Controller {      
    //This is my server    
    public function server(){
            if($this->uri->rsegment(3) == "wsdl") {
                $_SERVER['QUERY_STRING'] = "wsdl";
            } else {
                $_SERVER['QUERY_STRING'] = "";
            }

            //$ns= site_url()."cteam/cteam/server/wsdl";
            $ns= site_url()."cteam/cteam/wsdl";
            $endpoint = site_url()."cteam/cteam/server/wsdl";

            $this->load->library("Nusoap_library"); //load the library here
            $this->load->library('xmlrpc');
            $this->nusoap_server = new soap_server();

            $this->nusoap_server->configureWSDL('sever','urn:'.$ns,$endpoint);

            $this->nusoap_server->wsdl->schemaTargetNamespace='urn:'.$ns;

            $input_array = array ('count' => 'xsd:integer', 'type' => "xsd:string"); // method parameters
            $return_array = array ("fruit" => "xsd:string");

            $this->nusoap_server->register(
                'fruits', 
                $input_array, 
                $return_array, 
                "urn:SOAPServerWSDL", 
                "urn:".$ns."/fruits", 
                "rpc", 
                "encoded", 
                "Fruit Types"
            );

            function fruits($count,$type){
                switch($type){
                case 'red':
                    return $count." Apple";
                    break;
                case 'yellow':
                    return $count." banana";
                    break;                
                }
            }

            $this->nusoap_server->service(file_get_contents("php://input"));
        }

//This is my client
function test_soap2(){
       $this->load->library("Nusoap_library");
       $n_params = array("count" => 4, "type" => "red");

       $this->nusoap_client = new nusoap_client('http://localhost/desimd/cteam/cteam/wsdl/',array('soap_version' => SOAP_1_1));
       $this->nusoap_client->soap_defencoding = 'UTF-8';

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

       $result = $this->nusoap_client->call('fruits', array('parameters' => $n_params));
       echo $result;

       // 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>';
           }
       }

    }

    }

当我呼叫服务器时:http://localhost/desimd/cteam/cteam/wsdl/ 我正在获取xml。

当我致电客户时:http://localhost/desimd/cteam/cteam/test_soap2/ 它给了我错误: wsdl错误:解析WSDL的XML错误....标记不匹配

有人能帮助我吗?

0 个答案:

没有答案