views:

42

answers:

0

Hello,

What I want to accomplish is the following.

  1. Create a WCF webservice that is called by an android application.
  2. The webservice should return alot of information that is gathered from a large database. The information will consist of a View with 20 different tables with around 1-2 rows in each tables containing information.

The easiest way of sending the information from the WCF point of view is to create an XSD that represents the View itself, there I get a generated class in no time...

I have used KSOAP2 with android to call the webservice and get the information that I need.

But the big issue is how to be able to get the Data on the Androidside of the code in a readable and usable way.

Im open for suggestions of any kind that can help.

BUT here is where Im at now...

In my webservice I have a class called OracleView. This is just a testclass based on a table in my database. (Ive used this as a testsubject, the final result will be many times more advanced as mentioned earlier)

OracleView is an XSD generated class from a table in the database. Inside OracleView there is one table called News which has the following four collumns. ID, Message, NewsDate and ModifiedDate.

Here is the code which represents the WCF its a simple Interface.

[ServiceContract]
public interface IViewService
{
    [OperationContract]
    OracleView GetView();
}

Here is the code in my Androidapp that I use to call the service. Which works just nice.

private static final String SOAP_ACTION = "http://tempuri.org/IViewService/GetView";

private static final String METHOD_NAME = "GetView";

private static final String NAMESPACE = "http://tempuri.org/";

private static final String URL = "http://10.0.2.2/WcfViewService_deploy/ViewService.svc";

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.main);
findViewById(R.id.cmdCalculate).setOnClickListener(new OnClickListener() {
    public void onClick(View view) {
        ((TextView)findViewById(R.id.lblStatus)).setText("... Invoking Web Service ...");
        String stA = ((EditText)findViewById(R.id.numberA)).getText().toString();
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet=true;
        envelope.setOutputSoapObject(request);
        AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL);             
        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapObject result = (SoapObject)envelope.getResponse();

            ((TextView)findViewById(R.id.lblStatus)).setText(result.toString());
        } catch(Exception E) {
            ((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());
        }
    }           
});

The final result that I get from using toString is

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{simpleType=anyType{restriction=anyType{maxLength=anyType{}; }; }; }; element=anyType{}; element=anyType{}; }; }; }; }; }; unique=anyType{selector=anyType{}; field=anyType{}; }; }; }; diffgram=anyType{OracleView=anyType{News=anyType{ID=-1; Message=Testing1; NewsDate=2010-10-18T16:22:06.3234536+02:00; ModifiedDate=2010-10-18T16:22:06.3234536+02:00; }; News=anyType{ID=-2; Message=Testing2; NewsDate=2010-10-18T16:22:06.3234536+02:00; ModifiedDate=2010-10-18T16:22:06.3234536+02:00; }; }; }; }

Which as far as I can see is a representation on some parts of the XSD-structure which builds up OracleView. and then the content of the Table. This aint to much... But Having a view of 20 tables ... now thats a different story.