Skip to main content

Need to create dynamic Web Reference from XML Web Service consumer application

You can configure the web service to pull the URL based on a setting in a
configuration file, rather than a hardcoded value. To change the location,
simply change the config file with no recompile.

Here’s how to do it:
Add your web reference. Go to "Solution Explorer", right click on the web
reference name (eg. "localhost") and choose properties. In the property
window change "Url Behavior" from "Static" to "Dynamic".

If the web service client is a non-web application, this will automatically
create a file name app.config with the URL to the web service.


After you comiple your client app, the configuration file of it (such as
something.exe.config) will have the same content as the app.config.
Now, you can deploy the configuration along with the client executable. If
you ever need to change the web service location, you can open the
something.exe.config file in notepad and change the value attribute.

If the web service client is a web application such as web form,
changing "Url Behavior" from "Static" to "Dynamic" will automatically add
the same appsettings to web.config. Now, if you ever need to change the web
service location, you can open web.config file in notepad and change the
value attribute.

For Service URLs that change more often or at runtime, you can write custom
code to change the URL property off of the proxy class.


ws.Url = CompatibleCustomerServices(2) //bind to a the next compatible
service in the list

Outside VS.NET, you can use "wsdl.exe /urlkey:
to generatea proxy which
automatically checks in the for the given key.

When using "wsdl.exe /urlkey:myapplication.mywebservice.service1
for example, you should be
able to use the following configuration file to read the URL without any
further manual changes needed:

value=" />

Post a Comment

Popular posts from this blog

Compact and Repair an Access Database. Add Ref. to : AdoDb, Jro

< ?xml version="1.0" encoding="utf-8" ?>

using ADODB;
using JRO;
using System.Configuration;
using System.Data.OleDb;
using System.IO;

public class CompactAndRepairAccessDb : System.Windows.Forms.Form
private System.ComponentModel.Container components = null;
private JRO.JetEngine jro;
private System.Windows.Forms.Button btnConfirm;
private System.Windows.Forms.TextBox tbxOriginalDbSize;
private System.Windows.Forms.TextBox tbxCompactedDbSize;
private OleDbConnection cnn;

public CompactAndRepairAccessDb() {

FileInfo fi = new FileInfo( ConfigurationSettings.AppSettings["PathOriginal"] );
int s = Convert.ToInt32( fi.Length/1000 );
this.tbxOriginalDbSize.Text = s.ToString() + " kb";

private void btnConfirm_Click(object sender, System.EventArgs e) {
// First close all instances of the database

VBScript to Automate login into gmail

Dim IE
Dim crtScreen
Set IE = CreateObject("InternetExplorer.Application")
USERNAME = "saudaziz"

With IE
.navigate ""
End With

'wait a while until IE as finished to load
Do while IE.busy
set WshShell = WScript.CreateObject("WScript.Shell")
Do While UCase(IE.Document.readyState) <> "COMPLETE"
WScript.Sleep 100
set WshShell=nothing
IE.document.all.Item("Email").value = USERNAME
IE.document.all.Item("pASSWD").value =pASSWORD
Set IE = Nothing