0

I have a webservice in php:

<?php// incluyendo la librería de nusopa
require_once('./nusoap-0.9.5/lib/nusoap.php');

// Configurando el web service
$server = new soap_server();
$server->configureWSDL("SaludoXML", "urn:SaludoXMLwsdl");
$server->wsdl->schemaTargetNamespace = "urn:SaludoXMLwsdl";

// Registrando nuestra función Saludar con su parámetro nombre
$server->register(
        'Saludar', // Nombre del método
        array('nombre' => 'xsd:string'), // Parámetros de entrada
        array('return' => 'xsd:string'), // Parámetros de salida
        'urn:SaludoXMLwsdl', // Nombre del workspace
        'urn:SaludoXMLwsdl#Saludar', // Acción soap
        'rpc', // Estilo
        'encoded', // Uso
        'Saluda a la persona' // Documentación
);
$HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';   
$server->service($HTTP_RAW_POST_DATA);

And I have a class on android ClientWS:

package br.com.brunnosena.portalaluno;

import java.io.IOException;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONStringer;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.w3c.dom.Element;
import org.xmlpull.v1.XmlPullParserException;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;

public class ExemploWS extends AsyncTask<String, Integer, String> {
private Context context;

private static final String SOAP_ACTION = "SaludoXMLwsdl#Saludar";
private static final String OPERATION_NAME = "Saludar";
private static final String WSDL_TARGET_NAMESPACE = "SaludoXMLwsdl";
private static final String SOAP_ADDRESS = "http://10.1.14.19/webservice/loginApp/webservice.php";

public ExemploWS(Context context) {
    this.context = context;
}

@Override
protected String doInBackground(String... params) {

    String result = null;
    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
            OPERATION_NAME);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER10);

    // Con esta opción indicamos que el web service no es .net
    envelope.dotNet = false;
    envelope.setOutputSoapObject(request);

    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);

    // Enviando un parámetro al web service
    request.addProperty("nombre", params[0]);

    try {
        // Enviando la petición al web service
        httpTransport.call(SOAP_ACTION, envelope);

        // Recibiendo una respuesta del web service
        SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope
                .getResponse();

        result = resultsRequestSOAP.toString();

        //httpTransport.getServiceConnection().disconnect();
    } catch (IOException | XmlPullParserException e) {
        Log.v("Error", e.getMessage());
        result = e.getMessage();
    }

    return result;
}

@Override
protected void onPostExecute(String result) {
    // Mostramos la respuesta del web service
    Toast.makeText(context, result, Toast.LENGTH_LONG).show();
    }
}

If I put localhost in "SOAP_ADDRESS" it works. But if I put a different url example: http://brunnosena.com.br/webService/loginApp/webservice.php it appears to me the following error:

V/Error: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html lang='pt-br'>@2:20 in java.io.InputStreamReader@4e7c1f54) 

1 Answer 1

1

1.Can you please check in menifest file you have given below permission android.permission.INTERNET

  1. Try to change SOAP_ADDRESS = http://brunnosena.com.br/webService/loginApp/webservice.php?wsdl

I hope it will work

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks. It worked. But I put it in my domain for testing. I need to move to the domain of the company, and unfortunately it made the same mistake. [Link] vagas.qi.edu.br/webservice/loginApp/webservice.php [/link]. Can you help me?
Hi @Khushvinder. I tried but it made a mistake. I believe it's a locked port on this server. Do you know which door you could release?
For this you need to go on your hosting panel. on that place you can enable and disable the ports..
Hi @Khushvinder, but i do not know the number of port.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.