How to return a specific field from a WEB SERVICE SOAP

3

I need to return a specific field from my web service:

MainActivity class:

package com.example.paulogabriel.test_app;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

public class MainActivity extends Activity implements View.OnClickListener {

    private Button btn_login;
    private EditText mUser;
    private EditText mPass;
    private EditText amountEdit;
    private EditText resultEdit;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button button = (Button)findViewById(R.id.login);
        button.setOnClickListener(this);
    }


    public void onClick(View view) {
        EditText mUser = (EditText) findViewById(R.id.usuario);
        EditText mPass = (EditText) findViewById(R.id.senha);
        //amountEdit = (EditText) findViewById(R.id.amount_edit);
        resultEdit = (EditText) findViewById(R.id.TESTE);
        String CGC = "82270711000140";
        String ENTIDADE = "0";
        String RETORNO = null;
        String SENHA = mPass.getText().toString();
        String TIPO = null;
        String USERNAME = mUser.getText().toString();
        wsconnect service = new wsconnect();
        String result = service.Convert(CGC, ENTIDADE, RETORNO, SENHA, TIPO, USERNAME);
        resultEdit.setText(result);
        System.out.println(result);
    }
}

wsconnect class:

package com.example.paulogabriel.test_app;

import org.ksoap2.serialization.SoapObject;

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

public class wsconnect {
    private static final String SOAP_ACTION = "http://*********/acessoportal.apw/VALIDALOGIN";
    private static final String METHOD_NAME = "VALIDALOGIN";
    private static final String NAMESPACE = "http://************/acessoportal.apw";
    private static final String URL = "http://*************/ws/WEB015AP.apw?WSDL";

    public String Convert(String CGC, String ENTIDADE, String RETORNO, String SENHA, String TIPO, String USERNAME) {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("CGC", CGC);
        request.addProperty("ENTIDADE", ENTIDADE);
        request.addProperty("RETORNO", RETORNO);
        request.addProperty("SENHA", SENHA);
        request.addProperty("TIPO", TIPO);
        request.addProperty("USERNAME", USERNAME);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        try {
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
            return result.toString();
        } catch (Exception e) {
            return e.getMessage();
        }
    }
}

In my String result R.

This is my webservice:

     <VALIDACESSO>
        <CGC>STRING</CGC>
        <ENTIDADE>STRING</ENTIDADE>
        <MENSAGEM>STRING</MENSAGEM>
        <NOME>STRING</NOME>
        <NOMECGC>STRING</NOMECGC>
        <RETORNO>STRING</RETORNO>
        <USERNAME>STRING</USERNAME>
     </VALIDACESSO>
     <VALIDACESSO>
        <CGC>STRING</CGC>
        <ENTIDADE>STRING</ENTIDADE>
        <MENSAGEM>STRING</MENSAGEM>
        <NOME>STRING</NOME>
        <NOMECGC>STRING</NOMECGC>
        <RETORNO>STRING</RETORNO> <---- Esse é o campo que quero retornar na minha variável result no android.
        <USERNAME>STRING</USERNAME>
     </VALIDACESSO>
    
asked by anonymous 27.08.2016 / 19:15

0 answers