Tag Archives: MOSS

Windows Workflow Foundation: invokeWebService URL manipulating at runtime

The invokeWebservice Activity inside the Microsoft Workflow Foundation (WF) is a nice helper to get or send data from/to a webservice.

In Visual Studio 2008 you normally add the Webservice reference by referencing a URL and in most cases this URL will be a pointer to a development server. In production use you want to configure this URL of course. And here the pain begins. The invokeWebService Activity does not allow to edit the URL property at runtime. Instead you have to modify the runtime instance of the used proxy class.

You can do this by using this method in the invoking event of the activiy:

/// 
/// Called before the webservice is invoked. Here the URL can be configured during runtime by manipulating the proxy class
/// 
///

///
Webservice EventArgs including the instance of the proxy class
private void invokeGetMails_Invoking(System.Object sender, System.Workflow.Activities.InvokeWebServiceEventArgs e)
{
     service_ns.service proxy;
     proxy = (service_ns.service)e.WebServiceProxy;
     proxy.Url = this.wsUrl;

}