Tuesday, January 10, 2006

Passing credentials to a webservice from Workflow Foundation

You can call a webservice from within Workflow Foundation using the InvokeWebService activity. When you associate a webservice with the InvokeWebService activity it will create a proxy class. The InvokeWebService activity also provides an Invoking event handler. In the Invoking handler of the InvokeWebService activity, you can specify the Webserviceproxy credentials property. This proxy object is accessible as property of the WebServiceInvokeEventArgs argument.

private void Invokingwebservice(object sender, EventArgs e)
    wfService.Service svc = (wfService.Service)((WebServiceInvokeEventArgs)e).WebServiceProxy;
    svc.Credentials = System.Net.CredentialCache.DefaultCredentials;

No comments: