Understanding the .map File

Understanding the .map File

When you create a .NET program that uses a web service, Visual Studio .NET will create a file named References.map for each web service the program uses that contains specifics about the web service. You might use the contents of the .map file when you debug a client program that uses a web service. By viewing the contents of the Reference.map file, you can locate the URL of the web service on the Web. Then, using your browser, you can confirm that the web service still exists, view the web service’s WSDL entries for possible changes, and even interact with the methods you require.

For example, the following Visual Basic program UseRandomAndHello.vb uses the RandomNumber web service that you created in this chapter and the Hello web service you created in Chapter 2. To create the program, perform these steps:

  1. Within Visual Studio .NET, select the File menu New Project option. Visual Studio .NET will display the New Project dialog box.

  2. Within the New Project dialog box Project Types list, click Visual Basic Projects. Then, within the Templates field, click Windows Application. Finally, within the Location field, specify the folder within which you want to store the program and the program name UseRandomAndHello. Select OK. Visual Studio .NET will display a page onto which you can drag and drop the program’s controls (label, buttons, and text box).

  3. Using the Toolbox, drag and drop a button onto the form.

  4. Select the Project menu Add Web Reference option. Visual Studio .NET will display the Add Web Reference dialog box.

  5. Within the Address field, type localhost/Hello/Service1.asmx?WSDL and press Enter. The dialog box will load the file’s contents. Click your mouse on the Add Reference button.

  6. Select the Project menu Add Web Reference option. Visual Studio .NET will display the Add Web Reference dialog box.

  7. Within the Address field, type localhost/RandomNumber/Service1.asmx?WSDL and press Enter. The dialog box will load the file’s contents. Click the Add Reference button.

  8. Select the View menu Code option. Visual Studio .NET will display the program’s source code. Within the source code add the following program statements:

    Private Sub Button1_Click(ByVal sender As System.Object, _ ÂByVal e As System.EventArgs) Handles Button1.Click      Dim Ws As New localhost.Service1()    MessageBox.Show(Ws.HelloWorld(), "Hello Message")    Dim Ws2 As New localhost1.Service1()    MessageBox.Show(Ws2.RandomInteger0to1000(), "Random Number") End Sub

In this case, Visual Studio .NET will create two Reference.map files. The first will correspond to the Hello web service, as shown here:

<?xml version="1.0" encoding="utf-8"?> <DiscoveryClientResultsFile xmlns:xsd="http://www.w3.org/2001/XMLSchema"  Äxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">   <Results>     <DiscoveryClientResult Ä   referenceType="System.Web.Services.Discovery.ContractReference" Ä   url="http://localhost/Hello/Service1.asmx?wsdl" Ä   filename="Service1.wsdl" />   </Results> </DiscoveryClientResultsFile>

Likewise, the Reference.map file for the RandomNumber web service will contain the following:

<?xml version="1.0" encoding="utf-8"?> <DiscoveryClientResultsFile xmlns:xsd="http://www.w3.org/2001/XMLSchema"  Äxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">   <Resul;;ts>     <DiscoveryClientResult Ä   referenceType="System.Web.Services.Discovery.ContractReference" Ä   url="http://localhost/RandomNumber/Service1.asmx?wsdl" Ä   filename="Service1.wsdl" />   </Results> </DiscoveryClientResultsFile> 

Within the Reference.map file, the <DiscoveryClientResult> entry specifies the reference type (.disco, .wsdl, or .xsd) that corresponds to the URL of the web service’s reference file and a filename on the local system that contains the web service information.




. NET Web Services Solutions
.NET Web Services Solutions
ISBN: 0782141722
EAN: 2147483647
Year: 2005
Pages: 161
Authors: Kris Jamsa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net