I have been struggling with this issue to get to the root of it but no luck yet. My WebAPI runs in its own app pool in IIS and the actions is suppose to return XML and JSON but its only returns JSON. What is more strange is that it works fine on other PC so my guess is that it must be something wrong with my IIS or that I am missing a configuration of some sort. It works perfectly fine if I use Visual Studio Server but not IIS.
API Config:
//Added to support .net1.1 clients
config.Formatters.XmlFormatter.UseXmlSerializer = true;
config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
config.Formatters.Add(new FormUrlEncodedMediaTypeFormatter());
Data Property:
/// <summary>
/// Unique Transaction ID
/// </summary>
private int TransactionID;
[XmlElement(Type = typeof(int))]
public int fTransactionID
{
get{return TransactionID;}
set{TransactionID = value;}
}
Request Header
// Create a WebRequest to the remote site
WebRequest myWebClient = WebRequest.Create(uri);
myWebClient.ContentType = "application/xml";
myWebClient.Method = method;
EDIT
API Method
/// <summary>
/// Return Rebate Reversal Transactions
/// </summary>
/// <param name="FromDate"></param>
/// <param name="ToDate"></param>
/// <param name="PracticeID"></param>
/// <returns></returns>
[AttributeRouting.Web.Http.GET("RebateReversalTransaction/{FromDate}/{ToDate}/{PracticeID}")]
public GetRebateReversalTransactionResponse GetReversalTransaction(int FromDate, int ToDate, int PracticeID)
{
GetRebateReversalTransactionResponse reversalResponse = new GetRebateReversalTransactionResponse();
service = new PPNRebateSystemService();
reversalResponse = service.GetPracticeRebateReversalTransactions(FromDate, ToDate, PracticeID);
return reversalResponse;
}
ContentTypeof the request isapplication/xml?