Friday, 15 April 2011

c# - WCF service authentication fails -



c# - WCF service authentication fails -

i trying consume wcf service in console app. app.config file looks this

<configuration> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5" /> </startup> <system.servicemodel> <bindings> <wshttpbinding> <binding name="wshttpbinding_inventitemgroupservice" /> </wshttpbinding> </bindings> <client> <endpoint address="http://mydomain.com/microsoftdynamicsaxaif50/inventitemgroupservice.svc" binding="wshttpbinding" bindingconfiguration="wshttpbinding_inventitemgroupservice" contract="servicereference1.inventitemgroupservice" name="wshttpbinding_inventitemgroupservice"> <identity> <userprincipalname value="asd@as" /> </identity> </endpoint> </client> </system.servicemodel>

console app code create authentication part.

protected programclass(aifsos.inventitemgroupserviceclient inventitemgroupserviceclient) // constructor { minventitemgroupserviceclient = inventitemgroupserviceclient; // resharper disable 1 time possiblenullreferenceexception minventitemgroupserviceclient.clientcredentials.windows.clientcredential.username = "un"; minventitemgroupserviceclient.clientcredentials.windows.clientcredential.password = "pw"; minventitemgroupserviceclient.clientcredentials.windows.clientcredential.domain = "domain"; }

all seems okay me, throws error

the caller not authenticated service.

can 1 point out missing?

1 go client project properties.

a. go services tab

enable settings , utilize authentication mode windows

2 alter app.config file within client project 2 sample line

<security mode="none"> <transport clientcredentialtype="windows" proxycredentialtype="none" realm="" /> <message clientcredentialtype="windows" negotiateservicecredential="false" algorithmsuite="default" establishsecuritycontext="false" /> </security>

3 alter app.config file within service project

<security mode="none"> <message clientcredentialtype="windows" negotiateservicecredential="false" algorithmsuite="default" establishsecuritycontext="false" /> </security>

4 in client code when creating service instance , calling service utilize line provide login info in service pc.

service1client client = new service1client(); client.clientcredentials.windows.clientcredential.username = "etlit-1"; client.clientcredentials.windows.clientcredential.password = "etl"; client.clientcredentials.windows.allowntlm = false; client.clientcredentials.windows.clientcredential.domain = "etlit-1-pc"; console.writeline(client.addnumber(23, 2));

c# asp.net web-services wcf

No comments:

Post a Comment