• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nusoap in Code Igniter 1.5.4

#11
[eluser]heriniaina[/eluser]
Ok, solved.

I didn't put the "wsdl" parameter. So I put it.

Now it is like this:

Code:
$this->nusoap_client = new soapclient("http://radiovazogasy.com/wsdl/?wsdl", "wsdl");

and it works.

#12
[eluser]Cannyp[/eluser]
Hi there,

I've been struggling with getting NuSOAP integrated with CI in the way I would like.

I have got it working as described on the full example with Xajax (not using the Xajax part) but this is going to break the .NET clients that connect to me I think.

The way I have used NuSOAP before is to define/register all my functions and complex types in one script like so.

Code:
$server = new nusoap_server;
$NAMESPACE = 'http://my.namespace.com/';
$server->configureWSDL('SERVER','http://my.namespace.com/server_xsd/');
$server->wsdl->schemaTargetNamespace = 'http://my.namespace.com/server_xsd/';

$server->wsdl->addComplexType(
    'MyType1',
    //snip for brevity
);

$server->wsdl->addComplexType(
    'MyType2',
    //snip for brevity
);

$server->register('MyFunction1',
    array('id'=>'xsd:int'),
    array('return'=>'tns: MyType1'),$NAMESPACE);

$server->register('MyFunction2',
    array('id'=>'xsd:int'),
    array('return'=>'tns:MyType2'),$NAMESPACE);


function MyFunction1($id)
{
    $row["name"] = "test";
    return $row;
}

function MyFunction2($id)
{
    $row["name2"] = "test2";
    return $row;
}

$server->service($HTTP_RAW_POST_DATA);

//End Server
Then, in the client, in code (using NuSOAP) I would do:
Code:
$client = new nusoapclient("http://my.domain.com/server.php?wsdl",'wsdl');
$result = $client->call("MyFunction1", 123);

//End Client

This is similar to the way it get's called in .NET also. However, with the method described in the tutorial, It seems I cannot use the wsdl and need to point the client code to the individual functions defined on the server - which have been wrapped up in a nested function. What this means for the .NET clients is they will have to point to the wsdl for each function I have defined on my server - .NET provides a utility which generates all the C# stub code so this would generate a file for each function whereas before they just point to the server, it generates one file with all info in that file which they then import into their project. So all they require is the URL of the WSDL and it takes care of everything else, where as in this method they need to know they function names of the wrapper functions in CI. (At least thats my understanding of it so far but please point me in the right direction if im wrong here)

Is there anyway to get NuSOAP working with CodeIgniter as described above?

thanks.
Martin

#13
[eluser]Myles Wakeham[/eluser]
Digging up an old thread, but I'm in the same boat as Martin... I have multiple functions in my SOAP web services that are exposed and end users that run tools (in my case Delphi 2010) that consume these services through a 'WSDL Importer' that creates all the stub code automatically for them from the WSDL. These tools expect one WSDL to be available for ALL functions rather than individual WSDL URLs for each function.

If anyone has found a way to have one common WSDL URL that covers all functions and allows these external tools to work in harmony with the code, please post the solution.

Thanks
Myles

#14
[eluser]Cannyp[/eluser]
What I did to get it working was declare all the functions inside the index() function.

E.g.
Code:
<?php

class Soapy extends Controller
{

    function Soapy()
    {
        parent::Controller();    

        $this->load->library('Nusoap');
        $this->load->helper('functions');
        $this->nusoap_server = new nusoap_server();
        $this->nusoap_server->configureWSDL('Soapy',"http://example.com/Soapy_xsd/");
        $this->namespace = "www.example.com";
           $this->nusoap_server->wsdl->schemaTargetNamespace = "http://example.com/Soapy_xsd/";

        $this->nusoap_server->register('Login',
            array('username'=>'xsd:string', 'password' => 'xsd:string'),
            array('return'=>'xsd:string'),$this->namespace);
            
        $this->nusoap_server->register('Test',
            array('id'=>'xsd:int'),
            array('return'=>'xsd:string'),$this->namespace);
    }


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

        function Test($id)
        {
            return "Test Worked: $id";
        }
        
        /*
         * This get's called at the beginning of a session.
         *
         */
        function Login($username, $password)
        {
            $CI =& get_instance();
            // do your login whatever
        }

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


Then if you client has code generation from the WSDL type stuff you can do:
E.g. (with Python)

wsdl2py --url=http://www.example.tv/soap/soapy/wsdl


And then in the file it creates, you need to remove the "/wsdl" from the wsdl URL that it will generate. I hope that makes sense. I have tried this from Python and .NET and it works. This is what I had to do anyway becuase I dont allow ? query params which Nusoap expects.

I can't remember if I had to patch NuSoap to get around the ? problem. Feel free to PM me if that doesnt work and I will send you my nusoap.php file and a link to a live site.

Martin

#15
[eluser]Myles Wakeham[/eluser]
Interesting... Do you create any routes in routes.php in your Config to work with this?

#16
[eluser]Cannyp[/eluser]
Yes.

Code:
$route['soap/soapy/wsdl'] = 'soap/soapy/index/wsdl';


Hope that helps

#17
[eluser]Unknown[/eluser]
A good example of how to use nuSoap to connect to a .NET blog is explained here:

http://free biesms.blogspot.com/2009/01/send-free-sms-from-php.html

require_once('../lib/nusoap.php');
$useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';
$client = new soapclient('http://www.freebiesms.co.uk/sendsms.asmx?WSDL', 'wsdl');

#18
[eluser]marrysmile23[/eluser]
After a hard time trying to figure out how I can apply NuSOAP library in version 1.5.4 a solution occurred to me that I share with all of you who came across the same problem.

#19
[eluser]neverbewith[/eluser]
hi all,
first thanks for such a nice discussion here
i have a question, why it is not possible to use database functions in server function (at least i can't)
whenever i use $this->db->query("select * from table") it generate an error, but it is ok to use native php mysql functions or using CI models

thanx in advance

#20
[eluser]cahva[/eluser]
@neverbewith:
Please open a new thread about your problem. Your issue is clearly not connected to this thread. As for your problem, it seems to me that you havent loaded database but its hard to say without the error you get. So please start a new thread and add more information about the problem(error you get, piece of actual code and tell if that code is in library or controller or what).


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.