Wednesday, June 17, 2009

Calling WCF service from different domain

Scenario:
We had a requirement to call a WCF endpoint which was hosted in all together different domain. We had minimal trust between the domains. Creating direct proxy gave us SOAP Security Negotiation error.

This was Net TCP binding and we have Security mode Windows

Solution:
1. Create a local account on the server hosting the WCF Endpoint
2. Before opening the channel , set the client credentials as shown below.

Code:

//Connecting to WCF
var proxyClient = new MyWCFServiceClient();
proxyClient.ClientCredentials.Windows.ClientCredential.UserName = @"domain\username";
proxyClient.ClientCredentials.Windows.ClientCredential.Password = "sharepoint";
proxyClient.Open();
Follow me on Twitter

0 comments: