i am using a web service created in java in anothe rmachine and consuming it using rest client in C#.net while doing that i am getting an error saying "the remote server returned an error:unsupported media type 415"
...please fix my problem... i am using a console application and the code is as follows
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;
using System.Web;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
do
{
try
{
string content;
string Method = "POST";
string uri = "http://172.18.19.171:8080/RestDrools/rest/getPerson/personXML";
Console.WriteLine(uri);
HttpWebRequest req = WebRequest.Create(uri) as HttpWebRequest;
req.KeepAlive = false;
req.Method = Method.ToUpper();
if (("POST,PUT").Split(',').Contains(Method.ToUpper()))
{
string FilePath = "D://xyz.xml";
Console.WriteLine(FilePath);
content = (File.OpenText(@FilePath)).ReadToEnd();
byte[] buffer = Encoding.ASCII.GetBytes(content);
req.ContentLength = buffer.Length;
req.ContentType = "applicaton/xml";
Stream PostData = req.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
}
HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream =
new StreamReader(resp.GetResponseStream(), enc);
string Response = loResponseStream.ReadToEnd();
loResponseStream.Close();
resp.Close();
Console.WriteLine(Response);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
Console.WriteLine();
Console.WriteLine("Do you want to continue?");
} while (Console.ReadLine().ToUpper() == "Y");
}
}
}
[edit]Code block added - OriginalGriff[/edit]