I'm using this code to consume a SOAP web service from my Android app:
SoapObject request = new SoapObject(NAMESPACE, METHOD);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
Element headerElements[] = new Element[2];
headerElements[0] = new Element().createElement(HEADER_NAMESPACE,"locale");
headerElements[0].addChild(Node.TEXT,"es_MX");
Element authElement = new Element().createElement(HEADER_NAMESPACE,"authentication");
Element usernameElement = new Element().createElement(HEADER_NAMESPACE,"username");
usernameElement.addChild(Node.TEXT,"myUser");
Element pwdElement = new Element().createElement(HEADER_NAMESPACE,"password");
pwdElement.addChild(Node.TEXT,"pwd");
authElement.addChild(Node.ELEMENT, usernameElement);
authElement.addChild(Node.ELEMENT, pwdElement);
authElement.setPrefix(null, HEADER_NAMESPACE);
headerElements[1] = authElement;
envelope.headerOut = headerElements;
httpTransport.debug = true;
try {
httpTransport.call(SOAP_ACTION, envelope);
} catch (IOException | XmlPullParserException e) {
Log.e("myapp",e.getMessage(), e);
}
Log.i("dump request", httpTransport.requestDump);
but at the server side i'm getting an error like this:
Attribute 'id' is not allowed to appear in element 'n1:listAssignments'
...this is the XML request generated
<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>
<n0:locale xmlns:n0="http://mycompany.com/ws/soapheaders">es_MX</n0:locale>
<n1:authentication xmlns:n1="http://mycompany.com/ws/soapheaders">
<n1:username>myUser</n1:username>
<n1:password>pwd</n1:password>
</n1:authentication>
</v:Header>
<v:Body>
<n2:listAssignments id="o0" c:root="1" xmlns:n2="http://example.com/mx/mycompany/ws/webadjuster/WebAdjusterAPI" />
</v:Body>
</v:Envelope>
As you can see, the generated XML request contains an "id" and "c:root" atributes. Why is this happening? how can i avoid it?
Thanks in advance
add this code
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);"
Before this :
envelope.implicitTypes = true;
envelope.setAddAdornments(false);