How to Pass Windows Credentials along with Basic Credentials to WCF service

Last Reply 15 days ago By dharmendr

Posted 19 days ago

Hi,

When I try to consume a WCF service which needs Basic credentials, it was giving me error as "there was no end point....", but with help of this post " https://forums.asp.net/t/2162245.aspx There+was+no+endpoint+listening+at+https+ABC+redf+gov+sa+RedfFinance+Finance+svc+RedfFinance+that+could+accept+the+message+  "

I discussed with our n/w security team and set the proxy in the web.config and it worked, but it is not working in another computer. For that my n/w security team is asking me to pass my windows credentials before making call to WCF service, I am bit confused I am already passing 2 types of credentials 1. Basic 2. For each method. So kindly help me , how to pass the windows credentials before making call to WCF service, below is my code. Thanks.

ServiceReference1.FinanceClient objFinanceClient = new ServiceReference1.FinanceClient();
                objFinanceClient.ClientCredentials.UserName.UserName = "abc";
                objFinanceClient.ClientCredentials.UserName.Password = "123456";
                ServiceReference1.Credential objCredentials = new ServiceReference1.Credential();
                objCredentials.UserName = "xyz";
                objCredentials.Password = "123456";
                var Response = objFinanceClient.getRealEstateRegions(objCredentials);
                lblDisplay.Text = Response.RealEstateRegionResponse.ToString();


<system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IFinance" proxyAddress="http://1.2.3.4:8080" bypassProxyOnLocal="false" useDefaultWebProxy="false">
                    <security mode="Transport">
                        <transport clientCredentialType="Basic" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://webservice.abc.gov.sa/abcfinance.Finance.svc/abcfFinance"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFinance"
                contract="ServiceReference1.IFinance" name="WSHttpBinding_IFinance">
                <identity>
                    <dns value="webservice.redf.gov.sa" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>

 

You are viewing reply posted by: dharmendr 15 days ago.