1

I need to post an xmlData with a prametername to a webservice. My Code is

HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
request.Method = "POST";
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream());
requestWriter.Write(doc.InnerXml);
requestWriter.Close();
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

Using this I am able pass the data but parameter name is missing. So how to add a parameter name to the postdata?

Rn.
  • 167
  • 3
  • 6
  • 18

1 Answers1

1

You may send your request using Multipart form data approach, for instance you can find a sample code for it in the answer for the following question Multipart forms from C# client

Also you can try to encode your send text using UrlEncode and just send your data in the following format "fieldName=urlEncodedData"

Community
  • 1
  • 1
Victor
  • 618
  • 4
  • 12
  • but the xmldata contains some sensitive information . So i think the urlencoding will be a harmful approach. – Rn. Jun 25 '14 at 06:18
  • Why it is not good practice ? IF @Rn concern about sensitivity of data then you have to look for security option. – dotnetstep Jun 25 '14 at 08:07
  • @dotnetstep Ok, May I know what are those security options? – Rn. Jun 25 '14 at 08:40
  • You have to use encryption while you post data. Encrypt at your side and decrypt at Web Service receiver method. If we service not implemented by you then look for https hosted service. – dotnetstep Jun 25 '14 at 08:44
  • Does my comment help you ? – dotnetstep Jun 25 '14 at 15:31