Reputation: 11427
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
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
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
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