Error consuming webservice soap on android

1

I have a web service whose wsdl is this :

which rows the following if executed in the browser:

<!--
 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. 
-->
<!--
 Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. 
-->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://services.senior.com.br" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://services.senior.com.br" name="g5-senior-services">
<types>
<xsd:schema>
<xsd:import namespace="http://services.senior.com.br" schemaLocation="http://10.95.200.171:8000/g5-senior-services/rubi_Syncbr_com_cvale_Android?xsd=1"/>
</xsd:schema>
</types>
<message name="consultaLogin">
<part name="user" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="encryption" type="xsd:int"/>
<part name="parameters" type="tns:androidconsultaLoginIn"/>
</message>
<message name="consultaLoginResponse">
<part name="result" type="tns:androidconsultaLoginOut"/>
</message>
<portType name="rubi_Syncbr_com_cvale_Android">
<operation name="consultaLogin" parameterOrder="user password encryption parameters">
<input wsam:Action="http://services.senior.com.br/rubi_Syncbr_com_cvale_Android/consultaLoginRequest" message="tns:consultaLogin"/>
<output wsam:Action="http://services.senior.com.br/rubi_Syncbr_com_cvale_Android/consultaLoginResponse" message="tns:consultaLoginResponse"/>
</operation>
</portType>
<binding name="rubi_Syncbr_com_cvale_AndroidPortBinding" type="tns:rubi_Syncbr_com_cvale_Android">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="consultaLogin">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://services.senior.com.br"/>
</input>
<output>
<soap:body use="literal" namespace="http://services.senior.com.br"/>
</output>
</operation>
</binding>
<service name="g5-senior-services">
<port name="rubi_Syncbr_com_cvale_AndroidPort" binding="tns:rubi_Syncbr_com_cvale_AndroidPortBinding">
<soap:address location="http://10.95.200.171:8000/g5-senior-services/rubi_Syncbr_com_cvale_Android"/>
</port>
</service>
</definitions>

This webservice does not need to return anything, I just want to validate the user and the password.

This works perfectly if tested on the soapUI as below:

Sending with correct password:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.senior.com.br">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:consultaLogin>
         <user>fabio</user>
         <password>fabio</password>
         <encryption>0</encryption>
         <parameters>
            <!--Optional:-->
            <!--type: string-->
            <flowInstanceID></flowInstanceID>
            <!--Optional:-->
            <!--type: string-->
            <flowName></flowName>
         </parameters>
      </ser:consultaLogin>
   </soapenv:Body>
</soapenv:Envelope>

Return with correct password:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:consultaLoginResponse xmlns:ns2="http://services.senior.com.br">
         <result>
            <erroExecucao xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
         </result>
      </ns2:consultaLoginResponse>
   </S:Body>
</S:Envelope>

Incorrect password sending:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.senior.com.br">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:consultaLogin>
         <user>fabio</user>
         <password>teste</password>
         <encryption>0</encryption>
         <parameters>
            <!--Optional:-->
            <!--type: string-->
            <flowInstanceID></flowInstanceID>
            <!--Optional:-->
            <!--type: string-->
            <flowName></flowName>
         </parameters>
      </ser:consultaLogin>
   </soapenv:Body>
</soapenv:Envelope>

Return with incorrect password:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:consultaLoginResponse xmlns:ns2="http://services.senior.com.br">
         <result>
            <erroExecucao>Ocorreu um erro ao executar o serviço "Consulta Usuários": Credenciais inválidas.

Detalhes:Exception class: EBadAttempt</erroExecucao>
         </result>
      </ns2:consultaLoginResponse>
   </S:Body>
</S:Envelope>

I have the following code in my Activity on Android:

package br.com.fjsa16.webservice;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class MainActivity extends ActionBarActivity implements Runnable {

    private static final String SOAP_ACTION = "";
    private static final String METHOD_NAME = "consultaLogin";
    private static final String NAMESPACE = "http://services.senior.com.br";
    private static final String URL = "http://10.95.200.171:8000/g5-senior-services/rubi_Syncbr_com_cvale_Android";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        new Thread(this).start();
    }

    public void run() {
        validarUsuario();
    }

    public void validarUsuario() {
        SoapObject soap = new SoapObject(NAMESPACE, METHOD_NAME);

        soap.addProperty("user", "fabio");
        soap.addProperty("password", "fabio");
        soap.addProperty("encryption", 0);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(soap);

        Log.i("CVALE", "Consultando usuário...");
        HttpTransportSE httpTransport = new HttpTransportSE(URL);

        try {
            httpTransport.call(SOAP_ACTION, envelope);
            Object msg = envelope.getResponse();
            Log.d("CVALE", "Retorno: " + msg);
        } catch (Exception e) {
            Log.e("ERRO", "CATH DE BUSCA USUARIO!" + e.getMessage());
            finish();
        }
    }
}

And I'm having the following error:

05-22 11:47:39.310  20469-20469/? D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
05-22 11:47:40.120  20469-20469/br.com.fjsa16.webservice I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
05-22 11:47:40.120  20469-20469/br.com.fjsa16.webservice W/dalvikvm﹕ VFY: unable to resolve virtual method 405: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
05-22 11:47:40.120  20469-20469/br.com.fjsa16.webservice D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
05-22 11:47:40.120  20469-20469/br.com.fjsa16.webservice I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
05-22 11:47:40.120  20469-20469/br.com.fjsa16.webservice W/dalvikvm﹕ VFY: unable to resolve virtual method 427: Landroid/content/res/TypedArray;.getType (I)I
05-22 11:47:40.120  20469-20469/br.com.fjsa16.webservice D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
05-22 11:47:40.330  20469-20492/br.com.fjsa16.webservice I/CVALE﹕ Consultando usuário...
05-22 11:47:40.390  20469-20492/br.com.fjsa16.webservice D/dalvikvm﹕ GC_FOR_ALLOC freed 169K, 8% free 2952K/3188K, paused 58ms, total 60ms
05-22 11:47:40.490  20469-20469/br.com.fjsa16.webservice D/﹕ HostConnection::get() New Host Connection established 0xb84e1f18, tid 20469
05-22 11:47:40.570  20469-20469/br.com.fjsa16.webservice W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-22 11:47:40.590  20469-20469/br.com.fjsa16.webservice D/OpenGLRenderer﹕ Enabling debug mode 0
05-22 11:47:40.800  20469-20492/br.com.fjsa16.webservice D/dalvikvm﹕ GC_FOR_ALLOC freed 390K, 13% free 3067K/3524K, paused 38ms, total 38ms
05-22 11:47:40.930  20469-20492/br.com.fjsa16.webservice D/CVALE﹕ Retorno: anyType{erroExecucao=Não foi possível executar o serviço solicitado.
    Detalhes:
    Ação: SyncService -> Generate params
    Usuário: fabio
    Criptografia: 0
    Sem parâmetros de entrada
    Erro: null; }

It may be something simple to solve but as it is the first web service I'm consuming on android I'm catching up ...

Can anyone help me please?

    
asked by anonymous 22.05.2015 / 17:15

1 answer

-1

Hello, This "user" and "password" are for authentication in the database, that is, the first access must be a standard user, after authenticating in the next calls to the WebService you use the user and password of the person who logged in. So, on this port, you need to have other parameters that you will send the user and password of the person you are accessing, then return will come correctly!

    
07.10.2016 / 12:25