In android always execute catch block it doesent call method from the zend
Hello all i am trying to accees zend xmlrpc method in to android but it
always execute catch block is there any help... follwing is my code.
Android code Following is my android code for calling zend xmlapi.
below code pass url and call the method from the zend framework to the
test method of below activity it set the text value return from the zend
framework test method.
public class ClientActivity extends Activity {
private XMLRPCClient client;
private URI uri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_client);
System.out.println("Hello world");
uri = URI.create("http://10.0.2.2/tz/Examp2.php/api/?wsdl");
client = new XMLRPCClient(uri);
TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(testMethod());
}
private String testMethod() {
String text = "";
try {
text = (String) client.call("cmd.test");
} catch (XMLRPCException e) {
Log.w("XMLRPC Test", "Error", e);
text="Some error";
}
return text;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.client, menu);
return true;
}
}
and at zend side code my code is following which contain xml rpc server
it will return string value to the android device.
<?php
class Examp2Controller extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->_helper->viewRenderer->setNoRender();
$server = new Zend_XmlRpc_Server();
$server->setClass('Application_Model_Students', 'cmd');
echo $server->handle();
}
}
// This is a model code.
which contain one test method that i am trying to call
<?php
class Application_Model_Students
{
/**
* Test method
*
* @return string
*/
public function test()
{
return 'Hello XMLRPC!';
}
}
No comments:
Post a Comment