Paul Mendoza C# blog
Friday, January 05, 2007
  Web services with parameters

That HelloWorld example was good and all but it didn’t have any parameters. All that we need to do in order to add a parameter to our web service is add a parameter to the HelloWorld function. I’ve also changed it to return that same parameter as the response.




Now go and view the web service like we did before. You’ll notice that on the page with the “Invoke” button, it now also has a textbox for the string. You can type in your name into this textbox and when the “Invoke” is clicked, it will return the name like my code shows it should do.

With the parameters for a web service, you can add as many parameters as you need like you would any other function. If your parameters are primitives (ie. String, int…), you can use the test tools for the web service but if the parameters are your own custom objects or even objects like DateTime, the test tools won’t work. If you need to pass a DateTime object though, don’t convert it into a String just so that you can test it. It’s better to just pass the DateTime object.

Here is an example of what it would look like with just a string as the parameter like we've setup above.



 
Comments: Post a Comment





<< Home
I am currently an ASP.NET, C# developer working on MangosteenNation.com, a XanGo website for helping people build their businesses. I am also pursuing a degree at CSU San Marcos in Southern California.

XanGo at Mangosteen Nation

Archives
October 2005 / November 2005 / December 2005 / January 2006 / February 2006 / March 2006 / April 2006 / May 2006 / June 2006 / July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / January 2007 / April 2007 / May 2007 / June 2007 / August 2007 / February 2008 / August 2008 /


Powered by Blogger

Subscribe to
Posts [Atom]