JScript .NET, Part VII: Consuming add from ASP.NET: Defining A Virtual Directory - Doc JavaScript | WebReference

JScript .NET, Part VII: Consuming add from ASP.NET: Defining A Virtual Directory - Doc JavaScript


JScript .NET, Part VII: Consuming add from ASP.NET

Defining A Virtual Directory

We have showed you how to consume Web services from DHTML pages in Columns 97, 98, 99, 105, and 106. Consuming Web services from ASP.NET pages is not as straightforward as from DHTML pages, but it is not that complicated either.

The first new concept you have to deal with is the proxy. ASP.NET pages cannot interact directly with Web services. You need to create a proxy for the Web service you want to consume in your ASP.NET code. A proxy is a special component that masquerades as the service. The proxy insulates you from the location of the actual service. The location is captured once, when the proxy is created, and from then on you don't have to worry about where the Web service is. Creating a proxy for a Web service converts the Web service to a local component. In general, when you want to call a local component from your code, you need to access the component's class definition including its namespace, as well as its binary realization in the form of a dll. That's exactly what you get when you create a proxy for a Web service:

Before showing you how to create proxies, there is a security issue you need to be aware of. Once you create a proxy, you are left with a dll file. This library resides in a certain directory and is not known in other directories. You need to create this library in the same directory where you develop your ASP.NET pages. As we will show later in this column, your IIS Web server needs to have access to these pages. Therefore, you must make sure the directory you develop in is accessible by everyone. This is the default for directories that are at the root of your hard drives, as opposed to directories that are underneath your user name. A directory such as d:\aspDemo is, by default, accessible by everyone. The directory c:\Documents and Settings\Yehuda Shiran\My Documents\aspDemo, on the other hand, will not be accessible by Everyone. In Windows 2000, to verify the security level of your directory, right click its icon and pick Sharing.... The Security tab should have it accessible by Everyone, shown on this window:

Also, it is not sufficient to change the setting of your directory alone. You need to make sure all its parent directories can be accessible by Everyone.

In both Windows XP and Windows 2000, make sure you can share this directory on the Web. Web sharing is turned on automatically when you define your Web server's Default Web Site. When you assign the Default Web Site's directory on your hard drive, the IIS Web server changes that directory's Web Sharing properties. Suppose your directory is d:\aspDemo as we showed above. When you right-click its icon and pick Sharing and Security... in Windows XP or Sharing... in Windows 2000, you'd get the following Web Sharing tab:

As you can see, the directory already "knows" its alias on the IIS Web server: Column113. This registration is done automatically when you create your IIS virtual directory (more on this on the next page). Of course, a directory may have several aliases, i.e. it can be referenced by several default Web sites.

Next: How to create a proxy


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: June 30, 2002
Revised: June 30, 2002

URL: https://www.webreference.com/js/column113/3.html