Raja Afrika of the Afrika 8
Friday, April 19, 2024
 
Back to Raja's Blog

Raja's Blog
Not All Who Wander Are Lost

Martin Welch on Windows Communication Foundation (WCF) 101 - Part 3
Posted: Thursday, April 22, 2010

So I picked up my WCF project again and I was successful in creating my own very simple AJAX service. I did this by making a copy of the BASIC AJAX SERVICE example and overwriting the DoMath function with my own function that I call HelloWorld.

I very carefully changed all references to the method name in the .VB class. DoMathJson became HelloWorldJSON; DoMath became HelloWorld. I updated the DataContract changing the name of the datacontract class MathResult to SpeakResult. Lastly I modified the javascript in XmlAjaxClientPage.htm so that the body of my JSON input matches the parameters of my service call. Lastly I changed the function called when I click the "Perform Calculation (return JSON)" button to HelloWorld the name of my service method.

Problem that I ran into were the need to enclose string input in "Double Quotes." The input from the original example uses integers as inputs and thus does not need to wrap them in quotes. Not doing this caused a Request Error. The other problem encountered was that my WinHTTP Web Proxy Auto-Discovery Service appears to be required and the service can timeout and stop running throwing an error. During test I found it necessary to restart this service several times. I did not make any changes to the web.config or the Service.svc files.

Still, finally I got my new service returning a JSON object inclusive of the input that I specified in the input form. Rock'n!
Next Step:
Figure out how to return coplex types (i.e. datasets).

Code forth,

Martin Welch