Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old February 6th, 2012, 10:22 AM   #1 (permalink)
Junior Member
 
Join Date: Jan 2011
Posts: 19
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Default Axis2 web service Unknown type problem

This is my class where I encapsulate these parameters that I want to send via web service:
Code:
    public class GPSInfo implements KvmSerializable {

	private String latitude, longitude, info1, info2, info3;

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getInfo1() {
		return info1;
	}

	public void setInfo1(String info1) {
		this.info1 = info1;
	}

	public String getInfo2() {
		return info2;
	}

	public void setInfo2(String info2) {
		this.info2 = info2;
	}

	public String getInfo3() {
		return info3;
	}

	public void setInfo3(String info3) {
		this.info3 = info3;
	}

	@Override
	public Object getProperty(int arg0) {
		// TODO Auto-generated method stub

		switch (arg0) {
		case 0:
			return latitude;
		case 1:
			return longitude;
		case 2:
			return info1;
		case 3:
			return info2;
		case 4:
			return info3;
		default:
			break;
		}

		return null;
	}

	@Override
	public int getPropertyCount() {
		// TODO Auto-generated method stub
		return 5;
	}

	@Override
	public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
		// TODO Auto-generated method stub
		switch (arg0) {
		case 0:
			arg2.type = PropertyInfo.STRING_CLASS;
			arg2.name = "latitude";
			break;
		case 1:
			arg2.type = PropertyInfo.STRING_CLASS;
			arg2.name = "longitude";
			break;
		case 2:
			arg2.type = PropertyInfo.STRING_CLASS;
			arg2.name = "info1";
			break;
		case 3:
			arg2.type = PropertyInfo.STRING_CLASS;
			arg2.name = "info2";
			break;
		case 4:
			arg2.type = PropertyInfo.STRING_CLASS;
			arg2.name = "info3";
			break;
		}
	}

	@Override
	public void setProperty(int arg0, Object arg1) {
		// TODO Auto-generated method stub
		switch (arg0) {
		case 0:
			latitude=arg1.toString();
			break;
		case 1:
			longitude=arg1.toString();
			break;
		case 2:
			info1=arg1.toString();
			break;
		case 3:
			info2=arg1.toString();
			break;
		case 4:
			info3=arg1.toString();
			break;
		}
	}

}
and the web service class
Code:
    public String writeInfo(GPSInfo info) {
		String out = "success";
		try {
			
			System.out.println("LATITUDE JE:"+info.getLatitude());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return out;
	}
This is the code in my Android app where I invoke web service:
Code:
    String URL = "http://10.0.2.2:9090/GPSInfoWriter/services/GPSInfoWriter.GPSInfoWriterHttpSoap11Endpoint/";
				// String URL =
				// "http://192.168.2.103:9090/TestWS/services/GPSInfoWriter.GPSInfoWriterHttpSoap11Endpoint/";
				String SOAP_ACTION = "writeInfo";
				String METHOD_NAME = "writeInfo";

				SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
				PropertyInfo propertyInfo = new PropertyInfo();
 GPSInfo gpsInfo=new GPSInfo();
				 gpsInfo.setLatitude("14.4343543f");
				 gpsInfo.setLongitude("23.4343543f");
				 gpsInfo.setInfo1("info1");
				 gpsInfo.setInfo2("info2");
				 gpsInfo.setInfo3("info3");
request.addProperty("info",gpsInfo);
				//
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
						SoapEnvelope.VER11);
				envelope.setOutputSoapObject(request);
				envelope.addMapping(NAMESPACE, "GPSInfo",
						new GPSInfo().getClass());
//				envelope.addMapping(NAMESPACE,
//				 GPSInfo.class.getSimpleName(),GPSInfo.class);
				 HttpTransportSE androidHttpTransport = new
				 HttpTransportSE(URL);
				//
				 try {
				 androidHttpTransport.debug=true;
				 androidHttpTransport.call(SOAP_ACTION, envelope);
				 SoapObject response = (SoapObject)envelope.getResponse();
				 SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
				
				 System.out.println();
				
				
				 } catch (Exception e) {
				 e.printStackTrace();
				 System.out.println();
				 }

but I get this response from web server:
[ERROR] Exception occurred while trying to invoke service method writeInfo
org.apache.axis2.AxisFault: Unknow type {http://db.infoterm.com}GPSInfo

Can someone help me with this?Thanks.

pedjasmek is offline  
Reply With Quote
Sponsors
Old February 6th, 2012, 12:01 PM   #2 (permalink)
Senior Member
 
Join Date: Jul 2010
Posts: 977
 
Device(s): Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Thanks: 52
Thanked 199 Times in 144 Posts
Default

Can you post the logcat?
jonbonazza is online now  
Reply With Quote
Old February 7th, 2012, 04:19 AM   #3 (permalink)
Junior Member
 
Join Date: Jan 2011
Posts: 19
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by jonbonazza View Post
Can you post the logcat?
Logcat doesn't say much.I created test web service client and according to it,the correct request should contain this body:
Code:
<q0:writeInfo>
  <q0:info>
    <q1:latitude>visina</q1:latitude>
  </q0:info>
</q0:writeInfo>
You can notice that there is no type attribute in "info" node.If there is a type attribute,the server says unknown type.The problem is I cannot generate this request.
pedjasmek is offline  
Reply With Quote
Old February 7th, 2012, 02:40 PM   #4 (permalink)
Senior Member
 
Join Date: Jul 2010
Posts: 977
 
Device(s): Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Thanks: 52
Thanked 199 Times in 144 Posts
Default

You are getting a logcat, so it will definetly tell you something. Can you post it anyway?
jonbonazza is online now  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 12:14 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo