Using Web Service of WebServiceX.Net

I want to show you how to access a Web Services provided by www.webservicex.net. This website provides a set of useful web services.

Follow the instruction given below to create a client application that can send an SMS message to any mobile phone in India using a web service.

  1. Create a new website (File->New Web Site) using Visual Studio.NET 2005/2008. Call it webservicexclient.
  2. Goto solution explorer and select  Add Web Reference  option from  popup menu.
  3. In the given screen enter the following URL to access web service that can send a message to the given mobile number.
    http://www.webservicex.net/SendSMS.asmx?wsdl 
  4. Enter  webservicex  as the Web Reference Name.

Once the above process is through, VS.NET creates a proxy for the given web service.  Follow the steps given below to create a web form that takes required input  - mobile number and message, and send SMS using the proxy for the web service.

  1. Add a web form to the project using Website-> Add New Item ->Web Form. Give sendsms.aspx as the name of the form.
  2. Place a two text boxes - one for mobile number and another for shor message. Place a button to send message and then a label to display the status message.
  3. Write the following code the button.
  4. 
            protected void Button1_Click(object sender, EventArgs e) 
            {  
                webservicex.SendSMS s = new webservicex.SendSMS(); // create object of proxy
                s.SendSMSToIndia(TextBox1.Text,"srikanthpragada@yahoo.com", TextBox2.Text);  // send message.
                Label1.Text = "Message Sent Successfully!";
            }
            
            
  5. Run the form using  View in Browser option of Popup menu.
  6. Enter a mobile number and message. Click on Send Message button to send message.
  7. You must get message on the mobile in a few seconds (minutes) and also get message saying - Message sent successfully!.

There are some more interesting web services provide by this website.  For example, you can find out weather for a city in a country, check the validity of an email address etc.

If you find any other interesting web services of this kind, please share the information with me.

Have anything to say about this blog, please provide your opinion using Feedback Form .

Srikanth.