RESTful service not returning expected XML



I have a WCF Rest Service that currently returns an xml response as shown below.


xml response


However, it should be returned in the following format and I can't get it to output as such. Any help to get the correct output would be appreciated.



<app:get-order-details-response xmlns:apps="http://app.com/123/abc/">
<organisation-id>123</organisation-id>
<app2app-id>Mer001</app2app-id>
<order-id>100</order-id>
<order-price>0</order-price>
<response-handler>100</response-handler>
<failure-response-handler>0</failure-response-handler>
</app:get-order-details-response>


The code that generates the current xml is shown below. Is it because I'm returning an XmlElement? I've tried returning the XmlDocument and changing the code in the interface to do this, but that doesn't resolve this.



public XmlElement GetOrderDetails(string organisationID, string paymentReference, int paymentType, string deviceType)
{
.....
.....
.....
XmlDocument doc = new XmlDocument();

XmlElement root = doc.CreateElement("app:get-order-details-response", "http://app.com/123/abc/");
doc.AppendChild(root);
CreateElement(doc, root, "organisation-id", organisationID);
CreateElement(doc, root, "app2app-id", app2appID);
CreateElement(doc, root, "order-id", paymentReference;
CreateElement(doc, root, "order-price", paymentAmount);
CreateElement(doc, root, "response-handler", responseHandler);
CreateElement(doc, root, "failure-response-handler", failureResponseHandler);

return root;
}


Interface:



[ServiceContract]
public interface IPaymentService
{
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
Method = "GET",
UriTemplate = "/getorderdetails/v1/aa/order/{organisationID}/{paymentReference}?paymentType={paymentType}&deviceType={deviceType}")]
XmlElement GetOrderDetails(string organisationID, string paymentReference, int paymentType, string deviceType);
}

No comments:

Post a Comment