1

Tenho um web service cujo o wsdl é este:

que rotorna o seguinte se executado no navegador:

<!--
 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>

Este webservice não precisa retornar nada, só quero validar o usuário e a senha.

Isso funciona perfeitamente se testado no soapUI conforme abaixo:

Envio com senha correta:

<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>

Retorno com senha correta:

<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>

Envio com senha incorreta:

<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>

Retorno com senha incorreta:

<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>

Tenho o seguinte código na minha Activity no 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();
        }
    }
}

E estou tendo o seguinte erro:

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

Pode ser que seja algo simples de resolver mas como é o primeiro web service que estou consumindo no android estou apanhando...

Alguém pode me ajudar por favor?

1 Resposta 1

-1

Olá, Este "user"e "password" servem para autenticação no banco de dados, ou seja, no primeiro acesso deve ser um usuário padrão, depois de autenticado em próximas chamadas ao WebService você utilize o usuário e senha da pessoa que logou. Portanto, nesta porta, precisa ter outros parâmetros que você irá enviar o usuário e senha da pessoa que está acessando, aí retorno irá vir corretamente!

0

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .