How To Send the xml file to .net web service in android
<p>I want to send the xml file to .net web service but it did not work. In my project i have created xml file by using DOM Object. I want to send that Dom object to the server but It doent work.</p>

<p>I also used Ksoap2 jar file in my project. Please help me how to send the xml file to .net server. Here is my code:</p>

<pre><code>package com.Android.Xml;

import java.io.InputStream;
import java.io.StringWriter;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class BuildAndSend extends Activity {

    private static final String METHOD_NAME = "SaveXmlData";
    private static final String NAMESPACE = "http://tempuri.org/";
    //private static final String URL = "http://61.12.109.69/AndroidWebservice/Service.asmx";
    private static final String URL = "http://192.168.0.51/WebServiceExample/Service.asmx";
    final String SOAP_ACTION = "http://tempuri.org/SaveXmlData";
    TextView tv;
    Button send;
    StringBuilder sb;
    Document doc;
    DOMSource source;
    StringWriter writer ;
    InputStream inputStream;
    /** Called when the activity is first created. */
    String[] input = {"Bharath,9177049351", "Ramu,9866727992"};
    String[] line = new String[2];
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        sb = new StringBuilder();
        tv=(TextView)findViewById(R.id.text);
        send=(Button)findViewById(R.id.button1);
        send.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                call();
            }
        });

        DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
        DocumentBuilder builder;
        try {
            builder = factory.newDocumentBuilder();
            doc = builder.newDocument();
            Element root = doc.createElement("root");
            doc.appendChild(root);
            //Element memberList = doc.createElement("members");
           // root.appendChild(memberList);

            for (int i = 0; i &lt; input.length; i++) {
                line = input[i].split(",");

                Element member = doc.createElement("member");
                root.appendChild(member);

                Element name = doc.createElement("name");

                name.appendChild(doc.createTextNode(line[0]));
                member.appendChild(name);

                Element phone = doc.createElement("phone");
                phone.appendChild(doc.createTextNode(line[1]));
                member.appendChild(phone);
            }

            TransformerFactory tFact = TransformerFactory.newInstance();
            Transformer trans;

                try {
                    trans = tFact.newTransformer();
                    writer = new StringWriter();
                    StreamResult result = new StreamResult(writer);
                    source = new DOMSource(doc);
                    trans.transform(source, result);
                    System.out.println(writer.toString());
                     // call();
                } catch (TransformerConfigurationException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (TransformerException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }
    }    
    public void call() {
        try {

            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            PropertyInfo p=new PropertyInfo();
            p.setName("XmlFile");
            p.setValue(doc);
            p.setType(Document.class);
            request.addProperty(p);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive result = (SoapPrimitive)envelope.getResponse();           
            String resultData = result.toString();
            sb.append(resultData + "\n");
            } catch (Exception e) {
            sb.append("Error:\n" + e.getMessage() + "\n");
            System.out.println("error::::::::"+e.getMessage());
            }


        }
}
</code></pre>
