Problem complex types as return variable for SOAP webservice Client (Web service) with ksoap library for android

1 reply [Last post]
777ixoye777
User offline. Last seen 2 years 11 weeks ago. Offline
Joined: 11/21/2009

Hi



I used this tutorial https://www.blogger.com/comment.g?blogID=7256434358804236578&postID=4057530492593981404&page=1 and the ksoap liberary for android



BUT i have a problem with complex types of soap varaibles.



I have set up a coldfusion webserver. which has the following test webservice.



--------------------

Code:




<cfcomponent>



<cffunction name="getMessage" access="remote" returntype="any" output="no">



<cfargument name="vname" type="string" required="yes">

<cfargument name="nname" type="string" required="yes">

<cfset response = structnew()>


<cfset response.vname = arguments.vname>

<cfset response.nname = arguments.nname>

<cfreturn response>

</cffunction>

</cfcomponent>

---------



THE PROBLEM is that normal strings are comming threw but when I'm setting a complex type to this i can't get the attributes themselve What i get is the whole object as a string.




I looked to cast the object to a string Array Object but then a castexexption comes from Java



Next i tried this Android Client app with vectors but here they say illegal argument.



------------

Code:



import java.util.Vector;



import org.ksoap2.SoapEnvelope;

import org.ksoap2.serialization.SoapObject;

import org.ksoap2.serialization.SoapSerializationEnvelope;

import org.ksoap2.transport.AndroidHttpTransport;



import android.app.Activity;

import android.os.Bundle;


import android.view.View;

import android.view.View.OnClickListener;

import android.widget.EditText;

import android.widget.TextView;



public class test_ws_array extends Activity {

private static final String SOAP_ACTION = "getMessage";

private static final String METHOD_NAME = "getMessage";

private static final String NAMESPACE = "http://rpc.xml.coldfusion";

// !!!!! WICHTIG !!!!! IMMER NEUE IP EINTRAGEN DA SICH DIESE JEDESMAL AENDERT !!!!!

private static final String URL = "http://195.30.48.80:8500/DA/ws_functions/test4.cfc?wsdl";

//private static final String URL = "http://192.168.1.33:8500/DA/ws_functions/test.cfc?wsdl";






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

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.main);





//Buttons deaktiviert alles automatisch


SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

request.addProperty("vname", "Christian"

request.addProperty("nname", "Braun"



SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.setOutputSoapObject(request);

AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL);

try {

androidHttpTransport.call(SOAP_ACTION, envelope);




SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;

Vector XXXX = (Vector) resultsRequestSOAP.getProperty("[VNAME]"

//Vector XXXX = (Vector) resultsRequestSOAP.getProperty(0);





//Object result = envelope.getResponse();

//Object result = new Object();

//result = envelope.getResponse();



//Object[] results = (Object[]) result;


//2 Zeilen weg die sollten gehen mit Komplexen Objekttypen)

//String[] str = (String[]) result;

//((TextView)findViewById(R.id.lblStatus)).setText(resultsRequestSOAP.toString());

((TextView)findViewById(R.id.lblStatus)).setText(XXXX.toString());



//((TextView)findViewById(R.id.lblStatus)).setText(result.toString());

} catch(Exception E) {

((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());

}


}

}

------------



When i make a output with toString() method with the result then this is displayed on the screen:



getMessageResponse{getMessagereturn=Map{item=anyType{key=VNAME;value=Christian;}; item=anyType{key=NNAME; value=Braun;};};}



Maybe you can help me - this would be very helpful



Have you tried a complex Soap Type in a different way? And maybe have a sample app? Thanx!



Christian

yuri.brodner@gm...
User offline. Last seen 1 year 37 weeks ago. Offline
Joined: 05/09/2010
I'm coming up with the best

I'm coming up with the best solution for making money and fixing computers. It's a about a site which sells and buys used computer hardware and it's really good quality even if it's second hand. Try it yourself!