Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - Consuming a Service Created with Web Matri...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Consuming a Service Created with Web Matrix
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2006-03-28

    Table of Contents:
  • Consuming a Service Created with Web Matrix
  • Creating a client to the web service file
  • Using the reference to the mini-web server
  • Creating a web client in Web Matrix
  • Creating the client page and testing

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Consuming a Service Created with Web Matrix - Using the reference to the mini-web server


    (Page 3 of 5 )

    In this method, the reference to the mini-web server will be used to create a consumer of the web service created with Web Matrix using the VS 2003 IDE.

    Create an XML web service project having the file name miniweb.asmx as shown. Since it is a web service file, enter a class name and a namespace, as shown in Fig.7. The service will be known by its class name.

    Fig.7
    Fig.7

    The file will be added to the location shown in Fig.8. Since it is a demo for the client, just accept the default web service whose Web Method is Add () as shown. Notice that the class name is Cassini.

    Fig.8
    Fig.8

    Run this application by clicking on the Start arrow (blue colored) in the top menu. This brings up the Start Web Application window where you will use the ASP.NET Web Matrix server, herein called the mini-web server, as shown in Fig.9. 

    Fig.9
    Fig.9

    When you click on the Start button in the above screen, the server starts and you will see a screen similar to Fig.10. You may test this window by clicking on the Add hyperlink. You can also get a Service Description (the other hyperlink, not visible in this picture). Notice the URL with http at port 8890. Since this is an asmx file you can easily generate a wsdl file in the VS Studio 2003 by appending "? Wsdl" to the URL address.

    Fig.10
    Fig.10

    Now do not close the mini-web server. Create a Web application, TestMiniweb, which brings in a default web form1. Since this is a client consumer, provide a web reference by right clicking the node References and choose web reference. This opens up the wizard, which will locate the service. This can be browsed to find the mini-web service, or better still, paste the URL from the previous step, http://localhost:8890/miniweb.asmx?wsdl. This establishes the web reference.

    Open the code view of web form1 to display as seen in Fig.11 shown here. Since a reference has been established for the web service, you should add the appropriate Imports statement as shown. This page will be instantiating the web service with the new keyword which provides the correct object reference. The code added to write the mysvc.Add (3, 27) will send the arguments a=3, b=27 to the web service. The return value after being evaluated will be written to the screen. You may test this to find that the number 30 is written to the browser.

    Fig.11
    Fig.11

    If you stop your mini-web server and try to refresh the WebForm1.aspx, you will get an error. This service is only up as long as the mini-web server is working.

    More Visual Basic.NET Articles
    More By Jayaram Krishnaswamy


       · The tutorial shows how easy it is to create a consumer created with web matrix to...
     

    VISUAL BASIC.NET ARTICLES

    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway