Sean Kearon
Sean Kearon

Reputation: 11427

Easiest C# client to call an ASP.Net web service containing simple types without using Add Service Reference

What is the easiest way to call an ASP.Net web service using a C# client that uses only simple types? Easy here means:

Let's say that the web methods exposed by the service are something link this:

string SendSomething(string xml);
int GetNumber();

Upvotes: 0

Views: 492

Answers (3)

PraveenLearnsEveryday
PraveenLearnsEveryday

Reputation: 595

To some extent consumption of service also depends on how you implemented the service.Your requirement is exactly why we need more REST enabled web service.

Just in case if your service is REST enabled using WCF. you can try this http://praveenlearns.wordpress.com/2012/02/14/consuming-wcf-rest-service/

it shows how to consume REST services using GET/POST http verbs.

@Amn already suggested that you can call the web service from javascript using $(jquery).ajax method without adding any web service reference.

Upvotes: 0

Henk Holterman
Henk Holterman

Reputation: 273219

A WebMethod in an Asp.Net Webservice produces SOAP responses.

So unless you want to write the SOAP protocol again, the easiest way is to simply use a Web/Service reference.

For something lighter, it will have to start with changing the service. You could use the 'WCF dataservices' approach to create a JSON service.

Upvotes: 1

Aman
Aman

Reputation: 548

May be this is not exactly the answer you are looking for but certainly worth a try, you can try using jQuery AJAX to call your webmethods asynchrnously and it doesn't require you to add any service reference. Plus since you are working with simple types, calls would be much easier. You would have to be cautious in implementing the right security for your services however. Incase you fancy trying it, this is worth a look: Encosia . This site is all about what i have said above.

Cheers

Upvotes: 2

Related Questions