How to add prefix tag to soap using ksoap? I want to add : xmlns:cnx="http://db.hutt.com"
<v:Envelope xmlns:cnx="http://db.hutt.com" 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>
<authentication xmlns:n0="http://db.hutt.com">
<userName>tutt</userName>
<password>tutt@12345</password>
</authentication>
</v:Header>
<v:Body>
<cnx:get_tt xmlns="">
<ttid>1</ttid>
</cnx:get_tt>
</v:Body>
</v:Envelope>
So, it does not matter which ever tag you have example : v:Envelope or soapenv:Envelope. The soapserver will automatically parse it. Also, to add prefix in xml envelop you need to extend class SoapSerializationEnvelope.
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
/**
* Created by suamatya on 4/11/2017.
*/
public class CustomSoapSerializationEnvelope extends SoapSerializationEnvelope {
CustomSoapSerializationEnvelope(int version){
super(version);
}
@Override
public void write(XmlSerializer writer) throws IOException {
writer.setPrefix("i", xsi);
writer.setPrefix("d", xsd);
writer.setPrefix("c", enc);
writer.setPrefix("v", env);
writer.setPrefix("db","http://db.hott.com");
writer.startTag(env, "Envelope");
writer.startTag(env, "Header");
writeHeader(writer);
writer.endTag(env, "Header");
writer.startTag(env, "Body");
writeBody(writer);
writer.endTag(env, "Body");
writer.endTag(env, "Envelope");
}
}