0

Java (Tomcat) で Web サービスを作成しようとしていますが、kSoap を使用して Android から呼び出しています。私の webService が呼び出されたときのパラメーターは null です。どうしてか分かりません。

私の WebService のデータ

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());
    } 
}

私の Web サービス:

@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);
4

1 に答える 1

0

個人的には、ksoap を使用して .NET Web サービスに接続することに成功したので、Tomcat を使用するときにパラメーター名がどのように表示されるかわかりません。しかし、パラメータのデータ型を指定していないことに気付きました - これが問題でしょうか? 次に例を示します。

// ## init request parameters
PropertyInfo pi = new PropertyInfo();
// ## usuario
pi.setName("usuario");
pi.setValue(usuario);
pi.setType(String.class);
request.addProperty(pi);
于 2013-06-11T07:14:39.023 に答える