tags:

views:

55

answers:

1

Hi

I am trying to create a web service client for the android but i am stuck really bad Attached is my code and WSDL file. Please help

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package org.me.androidapplication1;

import android.app.Activity;

import android.os.Bundle;

import android.widget.TextView;

import java.io.IOException;

import java.util.logging.Level;

import java.util.logging.Logger;

import org.ksoap2.SoapEnvelope;

import org.ksoap2.serialization.SoapObject;

import org.ksoap2.serialization.SoapPrimitive;

import org.ksoap2.serialization.SoapSerializationEnvelope;

import org.ksoap2.transport.AndroidHttpTransport;

import org.xmlpull.v1.XmlPullParserException;


/**
*
* @author bansal
*/
public class MainActivity extends Activity {



private String SOAP_ACTION = "http://src/getNews";

private String METHOD_NAME = "getNews";

private String NAMESPACE = "http://src/";

private static final String URL ="http://128.205.201.202:8080/RssService
/RssServiceService?WSDL";

/** Called when the activity is first created. */
@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);


TextView tv = new TextView(this);

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

request.addProperty("ticker","NASDAQ:INFY");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.setOutputSoapObject(request);

AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);

try {

androidHttpTransport.call(SOAP_ACTION, envelope);

SoapPrimitive p = (SoapPrimitive) envelope.getResponse();

tv.setText("Response " + p);


} catch (Exception ex) {


ex.printStackTrace();

}


setContentView(tv);


// ToDo add your GUI initialization code here

}

}

Thanks

A: 

Move the Web Service call out of onCreate and do it in another thread. You don't want anything intensive going on in onCreate or it will hang up the creation and display of the activity.

BrennaSoft
I am not sure if the values of the variables are correct. CAn you check if they are based on my WSDL<definitions targetNamespace="http://src/" name="RssServiceService">−<types>−<xsd:schema><xsd:import namespace="http://src/" schemaLocation="http://128.205.201.202:8080/RssService/RssServiceService?xsd=1"/></xsd:schema></types>−<message name="getNews"><part name="parameters" element="tns:getNews"/>
BANSAL MOHIT