• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Axis2 web service Unknown type problem

pedjasmek

Newbie
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.
 
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.
 
Back
Top Bottom