START_TAG error {http://schemas.xmlsoap.org/soap/envelope/}

Asked

Viewed 163 times

0

When accessing a webservice made in php, on android presents me the following error:

 START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:7 in java.io.InputStreamReader@4e84b080) 

JAVA/Android:

/**


* Created by brunno.nascimento on 19/12/2016.
 */
package br.com.brunnosena.portalaluno;
import java.io.InputStreamReader;

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.AndroidHttpTransport;
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 SOAP_ACTION = "SaludoXMLwsdl#getUsuarioLogin";
//private static final String OPERATION_NAME = "getUsuarioLogin";
private static final String OPERATION_NAME = "Saludar";
private static final String WSDL_TARGET_NAMESPACE = "SaludoXMLwsdl";
private static final String SOAP_ADDRESS = "http://vagas.qi.edu.br/webservice/loginApp/webservice.php?wsdl";

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 = true;

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

PHP:

// including the cloud library 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
);

// Nuestra función que proporcionaremos
    function Saludar($nombre) {
        return 'Hola ' . trim($nombre);
    }

$HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';   
    $server->service($HTTP_RAW_POST_DATA);
  • Bruno post your code, so it is difficult to help, show what method you are trying to consume from the webservice

  • @Rodrigo.oliveira

  • Why you pass params[0] to the request?

  • Run a test by passing a string "with some name" and your xml version is Soapenvelope.VER10 anyway? is not 1.1?

1 answer

1


I looked at your URL by SOAPUI and saw that the version of your xml is 1.1 change the line

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER10);

To

 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
  • I did the test you asked for. I put any name, and in the version I changed to VER11. Still persists the same error. Next, I put in SOAP_ADDRESS" the local address of the server, and it worked. put in my domain, and it worked, but if I put the url, it doesn’t work.

  • By Soapui I also tried to access by your URL it returns me an error, @Brunnosena

  • Access to the application you Were trying to use has been blocked in accordance with company policy. Please contact your system Administrator if you Believe this is in error. This message comes in Um HTML and @Brunnosena

  • could be some lock on iis ? You know what this could be ?

  • Probably yes the title of this return HTML Application Blocked, and you said you are accessing normal with the local address.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.