Introduction: Generally we consume web services in web application, but there may be a need to call a web service in another web service application. As we know, a web application can consume more than one web service (here). In this article I am describing a simple way of calling a web service application in another web service application. A web service application can also call another web service. Here I will create two simple web services and will call one from another. At first we create a web service application. Follow the given steps.
Run this service application. Now create another ASP.NET Web Service Application (As above) and follow the given steps.
Now a web reference has added into your web service application. Now replace the code with the following code. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace secondwebservice { /// <summary> /// Summary description for Service1 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod(Description="Method of running web service")] public string show() { return "Method from second web service"; } [WebMethod(Description="Method of called web service")] public string display() { localhost.Service1 obj = new localhost.Service1(); return obj.show(); } } } Run the service. Output: Click at display ( method ) to go to test page and click the "invoke" button. Repeat the same for calling "show" method.
Consuming more than one Web Service in a Web Application
Working with Complex Data in a Web Service
Thanks buddy it very usefull very thanks
Thanks, Pravin.
nice article Alok....i think, will need it soon in my currnt poject.