My Java code:
import java.net.URI;
import java.util.Vector;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity {
String txtName, txtEmail, txtPassword, txtConfPassword;
TextView nameView, emailView, passView, confPassView;
private XMLRPCClient client;
private URI uri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public class RegistrarionTask extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
/*
* XmlRpcClient client = new XmlRpcClient(
* "http://www.danica.com.ar/recetario/recetario.wsdl");
* Vector<String> vector = new Vector<String>();
* vector.addElement(txtName); vector.addElement(txtEmail);
* vector.addElement(txtPassword); Object result = null; try {
* result = client.execute("Registration", vector);
*
* } catch (Exception e) { // TODO Auto-generated catch block
* e.printStackTrace(); }
*/
uri = URI
.create("http://www.danica.com.ar/recetario/recetario.wsdl");
client = new XMLRPCClient(uri);
String result = null;
try {
// result = (String) client.call("Registration");
result = (String) client.call("Registration", txtName,
txtEmail, txtPassword);
} catch (XMLRPCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
@Override
protected void onPostExecute(String result) {
if (result != null) {
}
}
}
public void onRegisterClick(View v) {
nameView = (TextView) findViewById(R.id.txtName);
nameView.requestFocus();
emailView = (TextView) findViewById(R.id.txtEmail);
passView = (TextView) findViewById(R.id.txtPass);
confPassView = (TextView) findViewById(R.id.txtConfPass);
txtName = nameView.getText().toString().trim();
txtEmail = emailView.getText().toString().trim();
txtPassword = passView.getText().toString().trim();
txtConfPassword = confPassView.getText().toString().trim();
if (txtName.equals("")) {
nameView.setError("This field is required!");
nameView.requestFocus();
return;
}
if (txtEmail.equals("")) {
emailView.setError("This field is required!");
emailView.requestFocus();
return;
}
if (!txtEmail.contains("@")) {
emailView.setError("Not a valid Email!");
emailView.requestFocus();
return;
}
if (txtPassword.equals("")) {
passView.setError("This field is required!");
passView.requestFocus();
return;
}
if (!txtPassword.equals(txtConfPassword)) {
confPassView.setError("Not a matching password!");
confPassView.requestFocus();
return;
}
new RegistrarionTask().execute();
}
}
and XML layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
<EditText
android:id="@+id/txtEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/txtPass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<EditText
android:id="@+id/txtConfPass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="Confirm Password"
android:inputType="textPassword" />
<Button
android:id="@+id/btnRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="54dp"
android:layout_marginTop="44dp"
android:onClick="onRegisterClick"
android:text="Register" />
But when I have run this code it gives exception this:
03-07 19:30:59.537: W/System.err(1016): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {null}methodResponse (position:START_TAG <definitions name='Recetario' targetNamespace='http://danica.com.ar/recetario' xmlns:tns='http://danica.com.ar/recetario' xmlns:xsd1='http://danica.com.ar/recetarioNamespace' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns='http://schemas.xmlsoap.org/wsdl/'>@9:43 in java.io.InputStreamReader@4122e1f8)
03-07 19:30:59.537: W/System.err(1016): at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
03-07 19:30:59.537: W/System.err(1016): at org.xmlrpc.android.XMLRPCClient.callEx(XMLRPCClient.java:200)
03-07 19:30:59.537: W/System.err(1016): at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:314)
03-07 19:30:59.537: W/System.err(1016): at com.example.kousikchatterjee.MainActivity$RegistrarionTask.doInBackground(MainActivity.java:59)
03-07 19:30:59.537: W/System.err(1016): at com.example.kousikchatterjee.MainActivity$RegistrarionTask.doInBackground(MainActivity.java:1)
03-07 19:30:59.547: W/System.err(1016): at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-07 19:30:59.547: W/System.err(1016): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-07 19:30:59.547: W/System.err(1016): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-07 19:30:59.547: W/System.err(1016): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
03-07 19:30:59.547: W/System.err(1016): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-07 19:30:59.547: W/System.err(1016): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-07 19:30:59.547: W/System.err(1016): at java.lang.Thread.run(Thread.java:856)
03-07 19:30:59.557: W/System.err(1016): org.xmlrpc.android.XMLRPCException: org.xmlpull.v1.XmlPullParserException: expected: START_TAG {null}methodResponse (position:START_TAG <definitions name='Recetario' targetNamespace='http://danica.com.ar/recetario' xmlns:tns='http://danica.com.ar/recetario' xmlns:xsd1='http://danica.com.ar/recetarioNamespace' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns='http://schemas.xmlsoap.org/wsdl/'>@9:43 in java.io.InputStreamReader@4122e1f8)
03-07 19:30:59.557: W/System.err(1016): at org.xmlrpc.android.XMLRPCClient.callEx(XMLRPCClient.java:237)
03-07 19:30:59.557: W/System.err(1016): at org.xmlrpc.android.XMLRPCClient.call(XMLRPCClient.java:314)
03-07 19:30:59.579: W/System.err(1016): at com.example.kousikchatterjee.MainActivity$RegistrarionTask.doInBackground(MainActivity.java:59)
03-07 19:30:59.579: W/System.err(1016): at com.example.kousikchatterjee.MainActivity$RegistrarionTask.doInBackground(MainActivity.java:1)
03-07 19:30:59.579: W/System.err(1016): at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-07 19:30:59.579: W/System.err(1016): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-07 19:30:59.587: W/System.err(1016): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-07 19:30:59.587: W/System.err(1016): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
03-07 19:30:59.587: W/System.err(1016): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-07 19:30:59.597: W/System.err(1016): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-07 19:30:59.597: W/System.err(1016): at java.lang.Thread.run(Thread.java:856)
03-07 19:30:59.607: W/System.err(1016): Caused by: org.xmlpull.v1.XmlPullParserException: expected: START_TAG {null}methodResponse (position:START_TAG <definitions name='Recetario' targetNamespace='http://danica.com.ar/recetario' xmlns:tns='http://danica.com.ar/recetario' xmlns:xsd1='http://danica.com.ar/recetarioNamespace' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns='http://schemas.xmlsoap.org/wsdl/'>@9:43 in java.io.InputStreamReader@4122e1f8)
03-07 19:30:59.607: W/System.err(1016): at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
03-07 19:30:59.617: W/System.err(1016): at org.xmlrpc.android.XMLRPCClient.callEx(XMLRPCClient.java:200)
03-07 19:30:59.617: W/System.err(1016): ... 10 more
Please provide me solve code on the basis of my code. Thanks in advance.
See Question&Answers more detail:os