SoapObject Result returns anyType{} as value

╄→гoц情女王★ 提交于 2019-12-06 05:17:19

Sorry to say i am not a Android developer so i coudn't provide you the exact answer but i can give you some hints what going wrong with my view point

Hopefully your Request is not that much cool to understand i guess by the server

What i think is your request is seems like this

REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/">
        <SOAP-ENV:Body>
            <ns1:getGramaNiladhariData/>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

so its returns this

stdClass Object
(
    [getGramaNiladhariDataResult] => stdClass Object
        (
            [gnName] => 
            [address] => 
            [workingDays] => 
            [gnDivision] => 
            [contactNumber] => 
        )

)

So Your Request must be like this

REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/">
        <SOAP-ENV:Body>
            <ns1:getGramaNiladhariData>
                <ns1:gndLifeCode>3-2-09-060</ns1:gndLifeCode>
            </ns1:getGramaNiladhariData>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

and then you will get the exact answer

And also make sure your tags of xmlns such as ns1, SOAP-ENV (in my case) these are same, to review that i recommend to use soap ui

Cool

the Imports:

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

Web service:

/*web service parameters*/
private static final String TAG = SearchResultFragment.class.getSimpleName();
private static final String SOAP_ACTION = "http://tempuri.org/GetMethod";
private static final String METHOD_NAME = "GetMethod";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://127.0.0.1/App_Services/service.asmx";

This is how i use it...

private SoapObject CallWebServiceDemo() {
    SoapObject result = null;
    try {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.implicitTypes = true;
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.XSD;
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.call(SOAP_ACTION, envelope);
        result = (SoapObject) envelope.getResponse();
    } catch (Exception ex) {
        Log.e(TAG, ex.getMessage());
    }
    return result;
}
Roma Asnani

Use this to change output to xml format:

httpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
httpTransport.call(SOAP_ACTION, soapEnvelope);
String resultString = httpTransport.responseDump;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!