I’d like to have our user landing web-server POST XML to our computation web server (to crunch over the XML data). The landing and computing web-servers are only connected via the internet – so it seems best to have a REST API on the computing web-server so the XML data can POSTed for processing.
To be honest, we’re all SW engineers but our competency is in the algorithmic processing, not the web plumbing or ASP.NET itself. I looked around and saw WCF (Windows Communication Foundation) being kicked around quite a bit. I’m concerned WCF might be too complex/over engineered for our situation.
So, what is the simplest way for me to enable the existing web-forms based processing website to accept POSTed XML? I guess I need to register a URI (in web.config?) as the API interface, have a handler on that URI and retrieve the XML string – I just don’t know the implementational steps :(. So a toy example or a pointer to a tutorial would be awesome!
BTW, once I have the XML string on the processing server, I’m golden!
Thanks
Sid
Ok, so I read up several documents to be able to answer my own question. Basically WCF REST has been changing quite a bit. It’s quite complicated in the setup in earlier versions but in recent versions (.NET 4 and WCF REST starter kit) the overhead of configuration is a lot less.
To get WCF REST running quickly, I basically did 3 things.
For very basic REST APIs (i.e. only HTTP GET) just the first two steps are sufficient. Please note, I scrubbed out some stuff during copy-pasting, but you should get the idea …
Step1a
global.asax
Step1b
global.asax.cs
Step2a
As you can see, I split the interface (abstract class) and the actual implementation into two separate files for clean separation.
TestInterface.cs
Step2b
TestService.cs
Step3
For the “test” example above, everything is over the URI itself (due to GET), so you don’t need the stuff below. Practically, once you want to use POST etc, you’ll need to send the object in the HTTP body. When exchanging Data, use a “Data Contract” to leverage WCF’s features as below.
Here I’ll be sending one class in the HTTP body, which in turn has one string and one int within.
TestInput.cs