Search code examples
androidksoap2android-ksoap2

ksoap2 android 1c different xml structure


ksoap2 generates xml like this

<?xml
    version="1.0"
    encoding="UTF-8"
    ?>
<env:Envelope>
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <env:Body>
        <tns:GetListClient>
            xmlns:tns="http://www.spr.org"
            hello
            </tns:GetListClient>
        </env:Body>
    </env:Envelope>

But web-service 1c, excepts only such xml-structured files

<soap:Envelope>
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        <soap:Header/>
        <soap:Body>
            <m:GetListClient>
                xmlns:m="http://www.spr.org"
                <m:Param/>
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                </m:GetListClient>
            </soap:Body>
        </soap:Envelope>

as you see the difference is in this params

xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Android code

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Celsius", "23");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.implicitTypes = true;

        envelope.setOutputSoapObject(request);
        Log.e("request", request.toString());

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;

        try {
            androidHttpTransport.call(SOAP_ACTION, envelope,headerProperty);
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            resultString = response.toString();
            Log.e("requestDumpCelsius",androidHttpTransport.requestDump);
            Log.e("responseDumpCelsius",androidHttpTransport.responseDump);
        } catch (Exception e) {
            e.printStackTrace();
            resultString = null;
        }
        if(resultString!=null)
        return resultString;
}

it gives me such exception

03-04 12:17:53.723    3932-3945/eu.msdlab.postmobile W/System.err﹕ SoapFault - faultcode: 'soap:Client' faultstring: 'Ошибка разбора SOAP сообщения: неизвестный параметр. ' faultactor: 'null' detail: org.kxml2.kdom.Node@41bf3470
03-04 12:17:53.723    3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:137)
03-04 12:17:53.723    3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
03-04 12:17:53.723    3932-3945/eu.msdlab.postmobile W/System.err﹕ at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)

What i need is to change structure of xml file but PropertyInfo allows me to add only one namespace

The problem solved Seems like i used wrong properties


Solution

  • As i understood your code ,this might be NAMESPACE Problem

    Try using

    private static String NAMESPACE = "http://tempuri.org/";
    

    If above don't work then

    private static String NAMESPACE = "xmlns:m="http://www.spr.org"";
    

    If above both not work for you then please post WSDL