Question

I hava a problem with envelope created using SoapSerializationEnvelope from ksoap2-android lib. What I need to get (what server expects) is that:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soa="http://agh.edu.pl/soa">
   <soapenv:Header/>
   <soapenv:Body>
      <soa:getCompanyById>
         <id>1</id>
      </soa:getCompanyById>
   </soapenv:Body>
</soapenv:Envelope>

What I actually get is that:

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
    <n0:getCompanyById id="o0" c:root="1" xmlns:n0="http://agh.edu.pl/soa">
        <id i:type="d:int">5</id>
    </n0:getCompanyById>
</v:Body>
</v:Envelope>

My Java Code:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        PropertyInfo id = new PropertyInfo();
        id.setName("id");
        id.setValue(5);
        id.setType(int.class);
        request.addProperty(id);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);      

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

        try {
            httpTransport.call(request.getNamespace() + "/" + request.getName(), envelope);
        } catch (Exception e)
        {
            System.out.println(httpTransport.requestDump);
            System.out.println(httpTransport.responseDump);
            System.out.println(e.getMessage());
        }

What i need to do is changing every v:something into soapenv:something and n0:getCompanyById into soa:getCompanyById. Any idea? Thanks in advance. Cya

Était-ce utile?

La solution

These envelopes are mostly the same - they just use different prefixes. What I would suggest is to use something like SoapUI: step by step, change working envelope to what you get from code. The moment things go bad you will know what is causing the problem.

From my experience i:type="d:int" may also cause the problem.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top