I have a WCF Service, using the basichttpbinding and windows authentication (no anonymous),
The WCF service is hosted in the domain server I need to consume the service from a server which is out of the domain, that server doesn't join domain, that is a workgroup. Is that possible? please help for a code snippet.
The configuration like below
<bindings>
<basicHttpBinding>
<binding name="defaultBinding" receiveTimeout="01:00:00" sendTimeout="01:00:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="defaultServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="defaultServiceBehavior" name="namespace.MyService">
<endpoint binding="basicHttpBinding" bindingConfiguration="defaultBinding" contract="namespace.IMyService">
<identity>
<dns value="abc.xyz.com"/>
</identity>
</endpoint>
</service>
</services>
Edited: here is my client code
_securityServiceClient = new SecurityServiceClient();
_securityServiceClient.ClientCredentials.UserName.UserName = "lto3";
_securityServiceClient.ClientCredentials.UserName.Password = "Lydowe@1982";
I got this error
An exception of type 'System.ServiceModel.Security.MessageSecurityException' occurred in mscorlib.dll but was not handled in user code
Additional information: The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Negotiate,NTLM'.
Try using:
_securityServiceClient.ClientCredentials.Windows.ClientCredential =
new NetworkCredential("lto3", "Ludowe@1982");
As per the msdn documentation ClientCredentials.Windows is how you specify the credentials to use when using windows authentication.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.