basvk
basvk

Reputation: 4546

ksoap2 nested items with similar namespace but different types

This is how the request envelope should look like:

<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>
    <getLijst xmlns="http://OAM/OMZETAPPMETHODS.xsd">
      <selectie i:type="n1:OAM_ArtstructselobjUser" xmlns:n1="http://OAM/OMZETAPPMETHODS.xsd">
        <filiaal i:type="d:decimal">4</filiaal>
        <artnivsel i:type="n1:OAM_ArtstructobjUser">
          <asonummer i:type="d:decimal">1</asonummer>
          <asotype i:type="d:string">P</asotype>
        </artnivsel>
      </selectie>
    </getLijst>
  </v:Body>
</v:Envelope>

And this is a part of my code:

String nameSpace = "http://OAM/OMZETAPPMETHODS.xsd";
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setAddAdornments(false);
SoapObject request = new SoapObject(nameSpace, _soapMethod);

OAM_ArtstructselobjUser obj = new OAM_ArtstructselobjUser();
// .. This is where the properties are added, irrelevant
request.addProperty("selectie", obj);

OAM_ArtstructobjUser obj2 = new OAM_ArtstructobjUser();
// .. This is where the properties are added, irrelevant
request.addProperty("artnivsel", obj2);

envelope.setOutputSoapObject(request);

Marshal floatMarshal = new MarshalFloat();
floatMarshal.register(envelope);

envelope.addMapping(nameSpace, "OAM_ArtstructselobjUser", OAM_ArtstructselobjUser.class);   
envelope.addMapping(nameSpace, "OAM_ArtstructobjUser", OAM_ArtstructobjUser.class);     

So I want artnivsel to have a custom type, but inherits the namespace of selectie. If I run the above code i get an 05-07 14:22:21.034: ERROR/AndroidRuntime(16417): Caused by: java.lang.RuntimeException: Unknown Property: asotype

If I change the nameSpace of the second addMapping to anything else, my code runs fine. But my envelope XML isn't correct. anymore.

Anyone who can give me a pointer, I'm not that experienced with ksoap2 or soap in particular.

Upvotes: 1

Views: 610

Answers (1)

basvk
basvk

Reputation: 4546

Okay looks like updating to ksoap2.6.4 fixes this. Just add avoidExceptionForUnknownProperty to true on the SoapSerializationEnvelope

Upvotes: 1

Related Questions