Welcome Guest, Not a member yet? Register   Sign In
Almost have NuSOAP working with CI, need a few tiny pointers...
#1

[eluser]Nathan Pitman (Nine Four)[/eluser]
So, I'm almost there with a simple web service (using http://codeigniter.com/wiki/CI_Nusoap_Library) that we need to serve using CI. When I access the URL of the web service I get the summary page with the available operations but clicking on the WSDL link from this page generates an 404 error whereas I was expecting XML output...

I also noticed that the URL in the address bar is: http://example.com/index.php/webservices/?wsdl yet I have a .htaccess file doing the old mod rewrite to the URLs of index.php...

This is my controller:

Code:
<?php
class Webservices extends Controller {

    function Webservices()
    {
        parent::Controller();
        $this->load->library('nusoap');
        
        $namespace = "http://example.com/webservices";
        $this->nusoap_server = new soap_server();
        $this->nusoap_server->configureWSDL("Web Services", $namespace);
        $server->wsdl->schemaTargetNamespace = $namespace;

        $this->nusoap_server->wsdl->addComplexType(
          'WebConnectionOutput',
          'complexType',
          'struct',
          'all',
          '',
          array(
            'MessageID' => array('name'=>'MessageID', 'type'=>'xsd:int'),
            'MessageText' => array('name'=>'MessageText', 'type'=>'xsd:string')
          )
        );
        
        $this->nusoap_server->register('WebConnection',
          array('AuthKey' => 'xsd:string'),
          array('return' => 'tns:WebConnectionOutput'),
          $namespace,
          $namespace . '#WebConnection',
          'rpc',
          'encoded',
          'Verify that a network connection exists'
        );
        
    }
    
    function index()
    {
      
        if($this->uri->rsegment(2) == "wsdl") {
            $_SERVER['QUERY_STRING'] = "wsdl";
        } else {
            $_SERVER['QUERY_STRING'] = "";
        }
        
        function WebConnection() {
            // Success
            $message_id = 1;
            $message_text = "You have successfully established a web connection.";

            // Return the result
            return array(
                "MessageID" => $message_id,
                "MessageText" => $message_text
            );
        }
        
        $raw_post = file_get_contents("php://input");
      $this->nusoap_server->service($raw_post);
    }

}
?>

I then have the following in routes.php:

Code:
$route['webservices'] = "webservices/index/wsdl";

I'm sure I'm doing something which is very obviously wrong but right now I can't spot it. Any help would be greatly appreciated. :)
#2

[eluser]mztest[/eluser]
why not use soap in directly on CI?
#3

[eluser]Nathan Pitman (Nine Four)[/eluser]
Hi mztest, we wanted to use NuSOAP because it was a technology we were more familiar with really, initially when we started work on the project there were also more usable examples of NuSOAP and CI than SOAP... add to that the fact that we were initially running this app on PHP4. Wink

All of that being said... we're now running on PHP5 so I guess we could migrate to a standard SOAP solution, it's nice to know the app could run on PHP4 if needed though.




Theme © iAndrew 2016 - Forum software by © MyBB