OK tech web services with android

OK tech web services with android

by snadly Mohamed Amine -
Number of replies: 1

hi moodlers smile

I am invoking this subject , beceause I tried to connect Ok teck web services with android in eclipse in order to cerate an adroid client application. But i'am not sure about the right way to do it .

I did run some of the ok teck web services in SOAPUI.

then I've picked the url, the namespace, the 'login' method name and it's soap action and I started to write the client code from android that call the 'login' method and retreive the client id and the sessionkey. but no luck so far! and here is the code :

package telnet.education.androodle;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;


public class LoginPage extends Activity {

private static final String SOAP_ACTION = "http://10.0.2.2/moodle/wspp/wsdl#login";

private static final String OPERATION_NAME = "login";

private static final String WSDL_TARGET_NAMESPACE = "http://10.0.2.2/moodle/wspp/wsdl";

private static final String SOAP_ADDRESS = "http://10.0.2.2/moodle/wspp/wsdl_pp.php" ;


@Override
public void onCreate(Bundle savedInstanceState)  {
super.onCreate(savedInstanceState);

TextView textView = new TextView(this);

setContentView(textView);

SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
OPERATION_NAME);
request.addProperty("username", "admin");
request.addProperty("password", "Shevchenko-7");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = false;

envelope.bodyOut=request;
envelope.setAddAdornments(false);

HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);

try

{

httpTransport.call(SOAP_ACTION, envelope);

Object response = envelope.getResponse();

textView.setText(response.toString());

}



catch (Exception exception)

{

textView.setText(exception.toString());

}


}
}

ps: localhost is 10.0.2.2 in the android emulator smile

be my guest to try the code yourself smile

So I'm wondering if someone have succeeded in invoking ok tech web services from android client.If so , then he can  tell us how he did it , and he can share his expertise  with us .thanks

greetings

Average of ratings: -
In reply to snadly Mohamed Amine

Re: OK tech web services with android

by Aldina Pljaskovic -

Hi, snadly.

Did you make your android client succesfully? I have some troubles when I work with forms. If in project is just one class similar as upper, it works, but when I add diferent forms and classes and call that class, lr=null (LoginRequest). Did you have some problem like this?