Welcome Guest, Not a member yet? Register   Sign In
XML-RPC request problem
#1

[eluser]kalpesh[/eluser]
Hi,
I try to workout webservice with CI.
This is my Home Controller
Code:
<?php
class Home extends Controller {

    function Home()
    {
    parent::Controller();
        $this->load->library('xmlrpc');
        }
  function index() {
    $this->Home_list();
  }
  function Home_list() {
    $this->load->library('user_agent');
    $this->load->helper('url'); // useful to check, parse and clean URLs
    
    $server_url = 'http://127.0.0.1/MobileSite/index.php/WebServer';
        $this->load->library('xmlrpc');
        $this->xmlrpc->set_debug(TRUE);
        $this->xmlrpc->server($server_url, 80);
        $this->xmlrpc->method('City');
        $request = array('city');
        $this->xmlrpc->request($request);
        if ( ! $this->xmlrpc->send_request())
            {
                    echo $this->xmlrpc->display_error();
            }
            else
            {
             $data['CityName']=$this->xmlrpc->display_response();
            }

  $this->load->helper('form');
  $this->load->model('form_model');
  $data = $this->form_model->general();
  $this->load->view('HomePage', $data);
  }
}
?>

The HomePage View like this:
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC '-//WAPFORUM//DTD XHTML Mobile 1.0//EN' 'http://www.wapforum.org/DTD/xhtml-mobile10.dtd'>
&lt;html &gt;
&lt;head profile="http://gmpg.org/xfn/11"&gt;
&lt;meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /&gt;
&lt;title&gt;City&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
</br>
<div id="Main Section" width="200px;" style="">
&lt;?php echo form_open('Home/input'); ?&gt;
    &lt;?php echo $SelectCity; ?&gt;:
    </br>
    &lt;?php echo form_dropdown('City',$CityName); ?&gt;
    </br>
    &lt;?php echo form_submit('mysubmit','Submit!');  ?&gt;
    &lt;?php echo form_close(); ?&gt;
</div>

&lt;/body&gt;
&lt;/html&gt;

This is My Webserver
Code:
&lt;?php
class WebServer extends Controller {

    function WebServer()
    {
        parent::Controller();
        $this->load->library('xmlrpc');
        $this->load->library('xmlrpcs');
    }
    function index()
    {
        $config['functions']['City'] = array('function' => 'WebServer.myfunction');
        $config['functions']['call2'] = array('function' => 'WebServer.myfunction2');
        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
    }
    function myfunction($request)
    {
    $this->load->database();
    $parameters = $request->output_parameters();
    $function = $parameters['0'];
    $query = $this->db->get('city');
    $i='0';
           foreach ($query->result() as $row)
            {
                 $row1[]=array(array(
                $row->City_Id =>$row->City_Name
            ),'struct');
            }
     $response=array($row1,'array');
    return $this->xmlrpc->send_response($response);
    }
}
?&gt;

But I get the errors
Please Help me.
thanks in advance.
#2

[eluser]kalpesh[/eluser]
I forgot to mention what errors i getting
This is error shown on page
Code:
---DATA---
HTTP/1.1 200 OK
Date: Sat, 21 Mar 2009 12:23:31 GMT
Server: Apache/2.2.3 (Win32) PHP/5.2.0
X-Powered-By: PHP/5.2.6
Content-Length: 937
Connection: close
Content-Type: text/xml


---HEADERS---
HTTP/1.1 200 OK
Date: Sat, 21 Mar 2009 12:23:31 GMT
Server: Apache/2.2.3 (Win32) PHP/5.2.0
X-Powered-By: PHP/5.2.6
Content-Length: 937
Connection: close
Content-Type: text/xml
---END HEADERS---

---DATA---
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<methodResponse>
<params>
<param>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>1</name>
<value>
<string>Mumbai</string>
</value>
</member>
</struct></value>
<value>
<struct>
<member>
<name>8</name>
<value>
<string>Delhi-NCR</string>
</value>
</member>
</struct></value>
<value>
<struct>
<member>

<value>
<string>Bangalore</string>
</value>
</member>
</struct></value>
<value>
<struct>
<member>
<name>4</name>
<value>
<string>Chennai</string>
</value>
</member>
</struct></value>
<value>
<struct>
<member>
<name>5</name>
<value>
<string>Hyderabad</string>
</value>
</member>
</struct></value>
<value>
<struct>
<member>
<name>6</name>
<value>
<string>Kolkata</string>
</value>
</member>
</struct></value>
<value>
<struct>
<member>
<name>7</name>
<value>
<string>Pune</string>
</value>
</member>
</struct></value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
---END DATA---

---PARSED---
object(XML_RPC_Values)#30 (29) {
  ["me"]=>
  array(1) {
    ["array"]=>
    array(7) {
      [0]=>
      object(XML_RPC_Values)#17 (29) {
        ["me"]=>
        array(1) {
          ["struct"]=>
          array(1) {
            [1]=>
            object(XML_RPC_Values)#16 (29) {
              ["me"]=>
              array(1) {
                ["string"]=>
                string(6) "Mumbai"
              }
              ["mytype"]=>
              string(1) "1"
              ["debug"]=>
              bool(false)
              ["xmlrpcI4"]=>
              string(2) "i4"
              ["xmlrpcInt"]=>
              string(3) "int"
              ["xmlrpcBoolean"]=>
              string(7) "boolean"
              ["xmlrpcDouble"]=>
              string(6) "double"
              ["xmlrpcString"]=>
              string(6) "string"
              ["xmlrpcDateTime"]=>
              string(16) "datetime.iso8601"
              ["xmlrpcBase64"]=>
              string(6) "base64"
              ["xmlrpcArray"]=>
              string(5) "array"
              ["xmlrpcStruct"]=>
              string(6) "struct"
              ["xmlrpcTypes"]=>
              array(9) {
                ["i4"]=>
                string(1) "1"
                ["int"]=>
                string(1) "1"
                ["boolean"]=>
                string(1) "1"
                ["string"]=>
                string(1) "1"
                ["double"]=>
                string(1) "1"
                ["datetime.iso8601"]=>
                string(1) "1"
                ["base64"]=>
                string(1) "1"
                ["array"]=>
                string(1) "2"
                ["struct"]=>
                string(1) "3"
              }
              ["valid_parents"]=>
              array(17) {
                ["BOOLEAN"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["I4"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["INT"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["STRING"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["DOUBLE"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["DATETIME.ISO8601"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["BASE64"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["ARRAY"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["STRUCT"]=>
                array(1) {
                  [0]=>
                  string(5) "VALUE"
                }
                ["PARAM"]=>
                array(1) {
                  [0]=>
                  string(6) "PARAMS"
                }
                ["METHODNAME"]=>
                array(1) {
                  [0]=>
                  string(10) "METHODCALL"
                }
                ["PARAMS"]=>
                array(2) {
                  [0]=>
                  string(10) "METHODCALL"
                  [1]=>
                  string(14) "METHODRESPONSE"
                }
                ["MEMBER"]=>
                array(1) {
                  [0]=>
                  string(6) "STRUCT"

I didnt know what happening here.
why i get this error.
#3

[eluser]Doosje[/eluser]
I don't think it's an error.
the output is there because of the " $this->xmlrpc->set_debug(TRUE);"
(as far is i know)
just comment that line out ..
#4

[eluser]kalpesh[/eluser]
there is an error in that file.
I comment debug.
But it giving me this error.
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: CityName

Filename: views/HomePage.php

Line Number: 16

A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: helpers/form_helper.php

Line Number: 268
#5

[eluser]Doosje[/eluser]
with this -> "$data['CityName']=$this->xmlrpc->display_response();" you make a variable in '$data' wich is loaded into views/Homepage.php
Over there it can't find the variable CityName.
#6

[eluser]kalpesh[/eluser]
Thanks its work
I really thankful to you.
For last 2 days i am trying this.
At last it is solved.
Can you give me example for webservice with Soap and wsdl in CI?
And again Thanks.
#7

[eluser]Doosje[/eluser]
I can''t but hopefully someone else can :-)
Good luck




Theme © iAndrew 2016 - Forum software by © MyBB