My web service sits between a client and another web service. It converts the clients requests into another request to pass on to Sage 300 and returns the response back. Most of the time it is for pushing data in or updating it. I'm working on getting data from the Sage system back to the client.
In the GetBalancesController I have: this function:
// GET api/<controller> public string Get([FromQuery] string c = "", string s = "")
It is returning a string at the moment. When the client makes a request it will be in the form:
https://localhost:44316/api/GetBalances?s=DEVDAT&c=1200
The parameters are not important. What is important is that when this URI is requested, my webservice constructs a call into Sage 300 to get what it needs. After a bit of work, it gets back the data I want and I alter it to what I need. If I serialise the data to an XML string I get this:
<?xml version="1.0" encoding="utf-16"?><CustomersBalances xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://accord.co.uk"><Value><CustomerBalances><CustomerNumber>1200</CustomerNumber><Terms>0</Terms><CreditLimitCustomerCurrency>10000</CreditLimitCustomerCurrency><BalanceDueInCustomerCurrency>5177.85</BalanceDueInCustomerCurrency><BalanceDueInFunctionalCurrency>7269.49</BalanceDueInFunctionalCurrency></CustomerBalances></Value></CustomersBalances>
That's great. But if I just return this to the Get function, it returns the XML as content rather than in the response body. How can I get the XML I've created from the return from Sage back to the client in the response body?
Thanks.