Hi,
I developed my own web service and wana to access it using ksoap2 at
android ..
i also tried for it but it didn`t work i am sharing my code and
exception if u have any idea regarding it then plz help me...
Code of Access web Service ::::::::
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import java.io.StringReader;
import java.util.Vector;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import android.widget.TextView;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
public class Test extends Activity
{
/** Called when the activity is first created. */
private static final String TAG = "Test";
private EditText mPath;
private ImageButton mPlay;
public String strpath;
private static final String SOAP_ACTION = "http://10.0.0.10:8080/
SearchService/SearchService/getXmlResult";
private static final String METHOD_NAME = "getXmlResult";
private static final String NAMESPACE = "http://
peteryeung.homeip.net/targetNamespaceBase/operation/message/
SearchService";
private static final String URL = "http://10.0.0.10:8080/
SearchService/SearchService";
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
mPath=(EditText)findViewById(R.id.path);
mPlay = (ImageButton) findViewById(R.id.play);
mPlay.setOnClickListener(new OnClickListener()
{
public void onClick(View view)
{
strpath= mPath.getText().toString();
Log.v(TAG, "path: " + strpath);
playVideo(strpath);
}
}
);
}
public void playVideo(String str)
{
try
{
SoapObject request = new SoapObject(NAMESPACE,
METHOD_NAME);
SoapObject parameters = new
SoapObject(NAMESPACE,
"getXmlResult");
parameters.addProperty("str", str);
request.addProperty(METHOD_NAME, parameters);
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport (URL);
androidHttpTransport.call(SOAP_ACTION,
envelope);
Object result = envelope.getResponse();
((TextView)findViewById(R.id.text)).append(result.toString());
SAXParserFactory spf =
SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
ParserHandler myExampleHandler = new
ParserHandler();
xr.setContentHandler(myExampleHandler);
xr.parse(new InputSource(new
StringReader(result.toString())));
// showResult(myExampleHandler.getResults());
}
catch(Exception e)
{
((TextView)findViewById(R.id.text)).append(""+e);
Log.e(TAG, e.getMessage(), e);
}
}
}
Exception are like tht:::::
org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://
schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG </{http://
schemas.xmlsoap.org/soap/envelope/}env:Fault>@2:595 in
[EMAIL PROTECTED])
E/AndroidRuntime( 554): at
org.kxml2.io.KXmlParser.exception(KXmlParser.java:243)
E/AndroidRuntime( 554): at
org.kxml2.io.KXmlParser.require(KXmlParser.java:1374)
E/AndroidRuntime( 554): at org.ksoap2.SoapEnvelope.parse(Unknown
Source)
E/AndroidRuntime( 554): at
org.ksoap2.transport.Transport.parseResponse(Unknown Source)
E/AndroidRuntime( 554): at
org.ksoap2.transport.AndroidHttpTransport.call(AndroidHttpTransport.java:
82)
E/AndroidRuntime( 554): at
com.android.i3content.Test.playVideo(Test.java:74)
E/AndroidRuntime( 554): at com.android.i3content.Test
$1.onClick(Test.java:56)
E/AndroidRuntime( 554): at android.view.View.performClick(View.java:
1515)
E/AndroidRuntime( 554): at
android.widget.ImageButton.performClick(ImageButton.java:80)
E/AndroidRuntime( 554): at android.view.View.onKeyDown(View.java:
2280)
E/AndroidRuntime( 554): at
android.view.KeyEvent.dispatch(KeyEvent.java:401)
E/AndroidRuntime( 554): at
android.view.View.dispatchKeyEvent(View.java:2206)
E/AndroidRuntime( 554): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)
E/AndroidRuntime( 554): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)
E/AndroidRuntime( 554): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)
E/AndroidRuntime( 554): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)
E/AndroidRuntime( 554): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:360)
E/AndroidRuntime( 554): at android.policy.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1071)
E/AndroidRuntime( 554): at
android.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:884)
E/AndroidRuntime( 554): at
android.app.Activity.dispatchKeyEvent(Activity.java:1377)
E/AndroidRuntime( 554): at android.policy.PhoneWindow
$DecorView.dispatchKeyEvent(PhoneWindow.java:1058)
E/AndroidRuntime( 554): at
android.view.ViewRoot.handleMessage(ViewRoot.java:564)
E/AndroidRuntime( 554): at
android.os.Handler.dispatchMessage(Handler.java:80)
E/AndroidRuntime( 554): at android.os.Looper.loop(Looper.java:71)
E/AndroidRuntime( 554): at
android.app.ActivityThread.main(ActivityThread.java:2506)
E/AndroidRuntime( 554): at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 554): at
java.lang.reflect.Method.invoke(Method.java:380)
E/AndroidRuntime( 554): at android.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:1170)
E/AndroidRuntime( 554): at
android.os.ZygoteInit.main(ZygoteInit.java:1121)
E/AndroidRuntime( 554): at android.dalvik.NativeStart.main(Native
Method)
On Mar 18, 1:06 pm, chitgoks <[EMAIL PROTECTED]> wrote:
> ok i hope someone else can help you. you probably need a Thread with this.
> and I havent touched Threads in android yet
>
> On Tue, Mar 18, 2008 at 4:04 PM, Florindo Renso <[EMAIL PROTECTED]>
> wrote:
>
> > my code is just in a try catch ...
> > My problem is this:
>
> > I need to create a connection timeout that after 6 seconds without
> > reciving a reply from the server close the connection and throws and
> > eception. Actually happen that my apllication remains blocked and the call
> > of the webservice, waiting the reply for a indeterminate time, so if for
> > some problem the webservice don't give a reply to the call the applicazion
> > was blocked in a infinite loop.
> > I hope to be clear this time
> > thx
>
> --
> Website:http://chitgoks.freehostia.com
> Java Casino Games:http://chitgoks.tripod.com
> My
> Blogs:http://chitgoks.blogspot.comhttp://wuhtevah.blogspot.comhttp://disneyusa.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---