R
Rafia Tapia
I have written a WCF service that is hosted in a console application. The
client is a asp.net application. I am exposing two endpoint, one is using
wshttpbinding and other is using nettcpbinding. Both are listening on
different ports and have the defualt bindings. So my understanding is that
with wshttpbinding, I will get message security and with tcp I would get
transport securtiy. My code works fine when both the client and server are
run on the same machine but when the client is running on a remote machine
it gives me the following error
"The caller was not authenticated by the service. "
Below is the app.config of the host running the service
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding">
<security mode="Message">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyService1Behavior"
name="ObjRetrievalService">
<endpoint address="ServiceViaWindowAuthHttp" binding="wsHttpBinding"
name="HttpWindowAuthSPObjRetrieval" contract="IObjRetrievalService"
listenUriMode="Explicit"></endpoint>
<endpoint address="ServiceViaWindowAuthTcp" binding="netTcpBinding"
name="TCPWindowAuthSPObjRetrieval" contract="IObjRetrievalService" />
<endpoint address="ServiceViaBasicAuthHttp" binding="wsHttpBinding"
bindingConfiguration="BasicHttpBinding" name="HttpBasicAuthSPObjRetrieval"
contract="IObjRetrievalService" />
<host>
<baseAddresses>
<add baseAddress="http://my-server:11021" />
<add baseAddress="net.tcp://my-server:11052" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyService1Behavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Below is the client code
WSHttpBinding bindingElement = new WSHttpBinding(SecurityMode.Message);
proxy = new ObjRetrievalServiceClient(bindingElement, new
EndpointAddress(UriAddress)));
What I want is that if on the login screen the user indicate that his
current login credentials should be use then he does not need to supply
username and password and in that scenario the first endpoint( on the server
config) will be used but if the user indicate userid/password on the login
form then the client app should communicate with the server by using the
third endpoint(server config). Since this application will be running in our
intranet, it makes sense to do a single sign on and the identity associated
with window login should be use for service authentication.
Can please help me and point me in some direction of what I am doing wrong.
client is a asp.net application. I am exposing two endpoint, one is using
wshttpbinding and other is using nettcpbinding. Both are listening on
different ports and have the defualt bindings. So my understanding is that
with wshttpbinding, I will get message security and with tcp I would get
transport securtiy. My code works fine when both the client and server are
run on the same machine but when the client is running on a remote machine
it gives me the following error
"The caller was not authenticated by the service. "
Below is the app.config of the host running the service
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding">
<security mode="Message">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyService1Behavior"
name="ObjRetrievalService">
<endpoint address="ServiceViaWindowAuthHttp" binding="wsHttpBinding"
name="HttpWindowAuthSPObjRetrieval" contract="IObjRetrievalService"
listenUriMode="Explicit"></endpoint>
<endpoint address="ServiceViaWindowAuthTcp" binding="netTcpBinding"
name="TCPWindowAuthSPObjRetrieval" contract="IObjRetrievalService" />
<endpoint address="ServiceViaBasicAuthHttp" binding="wsHttpBinding"
bindingConfiguration="BasicHttpBinding" name="HttpBasicAuthSPObjRetrieval"
contract="IObjRetrievalService" />
<host>
<baseAddresses>
<add baseAddress="http://my-server:11021" />
<add baseAddress="net.tcp://my-server:11052" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyService1Behavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Below is the client code
WSHttpBinding bindingElement = new WSHttpBinding(SecurityMode.Message);
proxy = new ObjRetrievalServiceClient(bindingElement, new
EndpointAddress(UriAddress)));
What I want is that if on the login screen the user indicate that his
current login credentials should be use then he does not need to supply
username and password and in that scenario the first endpoint( on the server
config) will be used but if the user indicate userid/password on the login
form then the client app should communicate with the server by using the
third endpoint(server config). Since this application will be running in our
intranet, it makes sense to do a single sign on and the identity associated
with window login should be use for service authentication.
Can please help me and point me in some direction of what I am doing wrong.