Android kSoap,当我在我的Web服务上获取参数时,它们的值是空的,为什么?
我正在尝试用Java(Tomcat)制作一个Web服务,我用kSoap从Android调用它。调用my webService时的参数为null。我不知道为什么 我的Web服务的数据Android kSoap,当我在我的Web服务上获取参数时,它们的值是空的,为什么?,android,web-services,soap,android-ksoap2,Android,Web Services,Soap,Android Ksoap2,我正在尝试用Java(Tomcat)制作一个Web服务,我用kSoap从Android调用它。调用my webService时的参数为null。我不知道为什么 我的Web服务的数据 Punto Final Información Nombre de Servicio\: {http://serv.trivial.com/}UsuariosWebServiceImplService Nombre de Puerto\: {http://serv.trivial.com/}Usuarios
Punto Final Información
Nombre de Servicio\: {http://serv.trivial.com/}UsuariosWebServiceImplService
Nombre de Puerto\: {http://serv.trivial.com/}UsuariosWebServiceImplPort
Dirección\: .../UsuariosWebService/usuarios
Clase de Implantación\: com.trivial.serv.UsuariosWebServiceImpl
我的代码是:
private void registroServidor(String usuario, String regId)
{
//http://localhost:8080/UsuariosWebService/usuarios?wsdl
final String NAMESPACE = "http://serv.trivial.com/"; //Buscar namespace en el wsdl
final String URL="http://10.0.2.2:8080/UsuariosWebService/usuarios";
final String METHOD_NAME = "createUser";
//final String SOAP_ACTION = "http://serv.trivial.com/createUser";
final String SOAP_ACTION = "";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("usuario", usuario);
request.addProperty("regGCM", regId);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
//envelope.doNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE transporte = new HttpTransportSE(URL);
try
{
transporte.call(SOAP_ACTION, envelope);
SoapPrimitive resultado_xml =(SoapPrimitive)envelope.getResponse();
String res = resultado_xml.toString();
if(res.equals("true"))
Log.d("GCMTest", "Registro WS: OK.");
}
catch (Exception e)
{
System.out.println("EXCEPTION!!!!!!" + e);
e.printStackTrace();
Log.d("GCMTest", "Registro WS: NOK. " + e.getCause() + " || " + e.getMessage());
}
}
我的网络服务:
@Override
@WebMethod
public boolean createUser(@QueryParam("usuario") String usuario,@QueryParam("regGCM") String regGCM) {
System.out.println("2222");
boolean result = false;
UsuarioDTO dto = new UsuarioDTO();
//!!!!!! regGCM and usuario are null!!!!!!
dto = new UsuarioDTO(regGCM, usuario);
if (dao.findUserByUsuario(usuario) != null){
result = dao.update(dto);
}else{
result = dao.insert(dto);
}
System.out.println("New User info: " + dto.toString());
return result;
}
@WebMethod
public abstract boolean createUser(@QueryParam("usuario") String usuario,@QueryParam("regGCM") String regGCM);
就我个人而言,我已经成功地使用ksoap连接到.NETWeb服务,所以我不确定使用Tomcat时您的参数名应该是什么样子。但是,我注意到您没有为参数指定数据类型-这可能是问题所在吗?下面是一个例子:
// ## init request parameters
PropertyInfo pi = new PropertyInfo();
// ## usuario
pi.setName("usuario");
pi.setValue(usuario);
pi.setType(String.class);
request.addProperty(pi);
我试图修复它,,,我认为这可能是因为在我的WSDL中,参数的名称类似于arg0,arg1,,,我用@WebParam(name=“…”)更改了它,但它仍然不起作用。有人能给我一个线索吗??非常感谢。