Web References

To simplify development of XML Web service client applications, Visual Studio provides the concept of Web references. A Web reference is a generated proxy class that locally represents the exposed functionality of an XML Web service. The proxy class defines methods that represent the actual methods exposed by an XML Web service. When the client application creates an instance of the proxy class, it is capable of calling the XML Web service methods as if the XML Web service was a locally available component.

Note   You need to explicitly specify the address and port of the proxy server on your network to make XML Web services outside the firewall available to the Web browser in the Web Reference dialog box.

The programming language in which the proxy class is generated is dependent upon the programming language of the active project to which the Web reference is added. If created independently of Visual Studio using one of the provided utilities, the programming language is dependent upon which utility you use. For WSDL.exe, you specify the programming language on the command line as either C# or Visual Basic. For SProxy.exe, the programming language is Visual C++.

At design time, the proxy class enables the developer to use statement completion in the Code Editor for the XML Web service methods. The actual implementation of the methods in the proxy class consists of code to package and send SOAP request messages and to receive and un-package any returned SOAP response message.

At run time, a call to a method of the proxy object is processed and encoded as a SOAP request message if the SOAP protocol is supported. If the XML Web service does not support SOAP, the proxy uses HTTP POST or HTTP GET. This message is then sent to the actual Web Service for processing. If the service description defines a response message, this proxy object processes this message and returns a response to the client application.

You can use the Web Reference URL property to specify the URL to the XML Web service. The Add Web Reference sets this property by default to the URL of the XML Web service you select, which is a static URL. A Web reference can use either a static URL or a dynamic URL.

If you leave the URL Behavior set to the default value of static, the proxy class sets the URL property using a hard-coded URL when you create an instance of the class.

If you set the URL Behavior property of the Web reference to dynamic, the application obtains the URL at run time from the <appSettings> Element of your application’s configuration file. When you specify a dynamic URL after adding a Web reference, Visual Studio updates the proxy class to obtain the URL from the configuration file.

   <add key="myApplication.myServer.Service1"

When you create an instance of a proxy object, you can also set the URL property of the object in your application.

Regardless of which URL the proxy uses, it must be for an XML Web service that adheres to a WSDL that matches the one used when adding the Web reference. For more information, see Managing Project Web References.

(sursa: http://msdn.microsoft.com/en-us/library/tydxdyw9(VS.71).aspx)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s