Last post Jul 03, 2018 01:28 PM by AnyUserNameThatLetsMeIn
Jul 03, 2018 12:08 PM|AnyUserNameThatLetsMeIn|LINK
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:
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">
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?
Jul 03, 2018 01:18 PM|mgebhard|LINK
Don't manually serialize, just return a typed object from the action and let the framework handle the details.
public TheType Get([FromQuery] string c = "", string s = "")
Jul 03, 2018 01:28 PM|AnyUserNameThatLetsMeIn|LINK
Haha :) I was just working through that before I saw your response. Seems like it is working now.