Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing i:type field in SOAP request generated by kSoap2 on Android

I already tried reading the internet about my issue, but I could not find the right information I need, so I try to explain my issue:

I am using kSoap2 to "talk" to a webservice over SOAP. To generate my SOAP request I use the following code:

// Generate SOAP request XML
SoapObject request = new SoapObject(PUB_NAMESPACE,
"testSoapInterface");   

// Add request header
PropertyInfo requestHeader = new PropertyInfo();
requestHeader.setNamespace(PUB_NAMESPACE);
requestHeader.setName("requestheader");

// Generate username property
PropertyInfo usernameProp = new PropertyInfo();
usernameProp.setNamespace(BASE_NAMESPACE);
usernameProp.setName("username");
usernameProp.setValue(username);

// Generate applicationId property
PropertyInfo applicationIdProp = new PropertyInfo();
applicationIdProp.setNamespace(BASE_NAMESPACE);
applicationIdProp.setName("applicationId");
applicationIdProp.setValue("test");

// Add properties to requestHeader (nested)
requestHeader.setValue(new SoapObject(PUB_NAMESPACE, "requestheader")
.addProperty(usernameProp)
.addProperty(applicationIdProp));

request.addProperty(requestHeader);

Now, to serialize this, I use the following:

// Serialize SOAP request to the non .NET based SOAP server
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = false;
soapEnvelope.implicitTypes = true;
soapEnvelope.setAddAdornments(false);
soapEnvelope.setOutputSoapObject(request);

Because I am using nested soap (the requestheader consists of applicationId and username) I can imagine that this might be the cause. I also have to use different namespaces for the different lines, which can also be a cause.

Can anybody help me on this?? Thanks!

like image 587
Niels_D Avatar asked Apr 24 '12 21:04

Niels_D


1 Answers

You can use implicitTypes property of your envelope:

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

In this way the generated xml will not contain i:type.

like image 197
Georgi Bilyukov Avatar answered Oct 29 '22 08:10

Georgi Bilyukov