mardi 4 août 2015

android retrieve data using soap

I know that the error has been asked by many people, but I just can't fix it by reading others. Below is the error message and coding.

08-04 22:02:07.405: W/result(16524): SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: loginCheck. 08-04 22:02:07.405: W/result(16524): at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() 08-04 22:02:07.405: W/result(16524): at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) 08-04 22:02:07.405: W/result(16524): at System.Web.Services.Protocols.SoapServerProtocol.Initialize() 08-04 22:02:07.405: W/result(16524): at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) 08-04 22:02:07.405: W/result(16524): at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)' faultactor: 'null' detail: org.kxml2.kdom.Node@424d65b0

=========================================================================

package com.example.dbConnection;

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

public class CallSoap 
{
     public final String SOAP_ACTION = "http://ift.tt/1VZcy7R";
public final String test = "loginCheck";
public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
public final String SOAP_ADDRESS = "http://ift.tt/1IhzpV3";
public CallSoap() 
{
}

public String test()
{
    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, test);

    PropertyInfo propertyInfo = new PropertyInfo();
    propertyInfo.setName("projectId");
    propertyInfo.setValue("321");
    propertyInfo.setType(String.class);
    request.addProperty(propertyInfo);

    propertyInfo.setName("loginName");
    propertyInfo.setValue("321");
    propertyInfo.setType(String.class);
    request.addProperty(propertyInfo);

    propertyInfo.setName("loginPw");
    propertyInfo.setValue("321");
    propertyInfo.setType(String.class);
    request.addProperty(propertyInfo);


    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;

    envelope.setOutputSoapObject(request);

    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);

    String response = null;

    try
    {
        httpTransport.call(test, envelope);
        response = envelope.getResponse().toString();
    }
    catch (SoapFault e)
    {
        response = e.toString();
    }
    catch (Exception e)
    {
        response = e.toString();
    }

    return response.toString();
}

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire