Dynamically binds to an XML Web service described in the discovery document at Url.
Assembly: System.Web.Services (in System.Web.Services.dll)
An XML Web service client can dynamically bind to an XML Web service other than the one referenced in the proxy class using the method. Typically, the Url property refers to the base address of the XML Web service. However, before invoking the method, set the Url property to a URL of a discovery document. The method attempts to find a match in the discovery document to the binding defined in the proxy class and then dynamically bind to it. If successful, subsequent method calls are directed to the XML Web service described in the discovery document.
If the proxy class is built using the Web Services Description Language tool (Wsdl.exe), the proxy class defines the binding implemented by the XML Web service methods it invokes using the WebServiceBindingAttribute. When an XML Web service implements multiple bindings, Wsdl.exe creates a proxy class for each binding. Applied to each proxy class is a WebServiceBindingAttribute that defines the name of the binding and its namespace. The discovery document you set the Url property to must contain a reference to an XML Web service that implements the same binding name and namespace, or an exception is thrown.
The following code example is a proxy class generated using the Wsdl.exe utility for the Math XML Web service. A WebServiceBindingAttribute is applied to the Math proxy class setting the binding name to MathSoap and its namespace to http://tempuri.org/.
The following code example is a Web Service client using the preceding proxy class. Within the EnterBtn_Click event of the Web Form, the XML Web service client calls the method attempting to dynamically bind to the URL supplied by the user.
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.