我无法解决这个问题并继续……我的应用程序有一个大问题。任何帮助将不胜感激,我将尝试放置所有代码。
非常感谢!
主要错误是这个:
[ERROR] Exception occurred while trying to invoke service method almacenaCoordenadas
org.apache.axis2.AxisFault: Unknow type {http://www.w3.org/2001/XMLSchema}Coordenada
我要发送的复杂对象是这个:
import java.util.Hashtable;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class Coordenada implements KvmSerializable {
private long longitud;
private long latitud;
public Coordenada(long lat, long lon) {
longitud = lon;
latitud = lat;
}
public void setLongitud(long lon) {
longitud = lon;
}
public void setLatitud(long lat) {
latitud = lat;
}
public long getLongitud() {
return longitud;
}
public long getLatitud() {
return latitud;
}
@Override
public Object getProperty(int arg0) {
switch (arg0) {
case 0:
return latitud;
case 1:
return longitud;
}
return null;
}
@Override
public int getPropertyCount() {
return 2;
}
@Override
public void setProperty(int ind, Object val) {
switch(ind){
case 0:
latitud = Long.parseLong(val.toString());
break;
case 1:
longitud = Long.parseLong(val.toString());
break;
default:
break;
}
}
@Override
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
switch(arg0){
case 0:
arg2.type = PropertyInfo.LONG_CLASS;
arg2.name = "latitud";
break;
case 1:
arg2.type = PropertyInfo.LONG_CLASS;
arg2.name = "longitud";
break;
default:break;
}
}
}
我通过调用此方法发送它:
private String almacenaCoordenadas() {
accionSoap = "http://ws.webapp.org/almacenaCoordenadas";
metodo = "almacenaCoordenadas";
String retorno="";
try {
// Modelo el request
SoapObject request = new SoapObject(namespace, metodo);
PropertyInfo primerParametro = new PropertyInfo();
PropertyInfo segundoParametro = new PropertyInfo();
//PropertyInfo tercerParametro = new PropertyInfo();
primerParametro.setName("id");
primerParametro.setValue(user);
segundoParametro.setName("coord");
segundoParametro.setValue(coordenada);
request.addProperty(primerParametro);
request.addProperty(segundoParametro);
/*
segundoParametro.setName("lo");
segundoParametro.setValue(longitud);
tercerParametro.setName("lat");
tercerParametro.setValue(latitud);
request.addProperty(primerParametro);
request.addProperty(segundoParametro);
request.addProperty(tercerParametro);*/
// Modelo el Sobre
SoapSerializationEnvelope sobre = new SoapSerializationEnvelope(SoapEnvelope.VER11);
// si esta hecho o no en puntoNet
sobre.dotNet = false;
sobre.setOutputSoapObject(request);
sobre.AddMapping(namespace, "Coordenada", new Coordenada().getClass();
// Modelo el transporte
HttpTransportSE transporte = new HttpTransportSE(url);
// Llamada
System.out.println(sobre);
transporte.call(accionSoap, sobre);
// Resultado
SoapPrimitive resultado = (SoapPrimitive) sobre.getResponse();
retorno = resultado.toString();
if (retorno!=null)
Log.i("Resultado", "Envio correcto de coordenada");
} catch (Exception e) {
String s="";
s+="ERROR - Envio de coordenada\n";
s+=e.toString();
Log.e("MainActivity",s);
}
return retorno;
}
从这个:(是一个AsyncTask)
@Override
protected String doInBackground(String... params) {
almacenaCoordenadas();
return null;
}
Web服务中的方法是这样的:
public String almacenaCoordenadas(String id, Coordenada coord){
String resultado="Coordenadas recibidas correctamente";
System.out.println(id+" esta en las coordenadas:");
if(coord!=null){
System.out.println("Llega coordenada");
}
return resultado;
}
错误是这个:
[ERROR] Exception occurred while trying to invoke service method almacenaCoordenadas
org.apache.axis2.AxisFault: Unknow type {http://www.w3.org/2001/XMLSchema}Coordenada
at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:340)
at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:818)
at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:737)
at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:646)
at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:206)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
看起来网络服务无法处理对象 Coordenada ..
任何帮助,将不胜感激。非常感谢!!