-2

I need to print XML for request, not response.

Object response = null;

    String METHOD_NAME = "GenerateOtp";// GenerateOTP

    String NAMESPACE = "http://com/abc/ppi";

    String URL = "http://name.com/methodname/";

    // String SOAP_ACTION = NAMESPACE+"/"+METHOD_NAME ;

    String SOAP_ACTION = "";

    try {

        // String xml = xmlns="java:com.abc.ppi.request" ;

        SoapObject RequestParent = new SoapObject("", METHOD_NAME);

        SoapObject Request1 = new SoapObject("", "request");

        PropertyInfo pi = new PropertyInfo();
        pi.setNamespace("http://com/abc/ppi");
        pi.setName("DeviceId");
        pi.setValue(DeviceId);
        Request1.addProperty(pi);

        pi = new PropertyInfo();
        pi.setNamespace("http://com/abc/ppi");
        pi.setName("DeviceType");
        pi.setValue(DeviceType);
        Request1.addProperty(pi);

        SoapObject HeaderRequest = new SoapObject("","HeaderTag");

        pi = new PropertyInfo();
        pi.setNamespace("java:com.abc.ppi.request");
        pi.setName("MobileNo");
        pi.setValue(MobileNo);
        HeaderRequest.addProperty(pi);

        Request1.addSoapObject(HeaderRequest);

        RequestParent.addSoapObject(Request1);

        Log.v("upi", "RequestParent:" + RequestParent);

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

soapEnvelope.dotNet = false;

soapEnvelope.setOutputSoapObject(RequestParent);

HttpTransportSE transport = new HttpTransportSE(URL);

transport.call(SOAP_ACTION, soapEnvelope);

response = (Object) soapEnvelope.getResponse();

Used Jar : ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar Android note: I want to print this xml soap request into XML FORMAT like this.. I need to view this xml request before going to make request to soap webservices.I can able to see this request format from webservices java server side. But, I want to see this request from Android Client Side. ? ? ?

harikrishnan
  • 1,985
  • 4
  • 32
  • 63

1 Answers1

-1
public static void printXML(Document document, OutputStream output) throws IOException, TransformerException {
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

    transformer.transform(new DOMSource(document), 
         new StreamResult(new OutputStreamWriter(output, "UTF-8"))); }
Victor Viola
  • 575
  • 1
  • 4
  • 14