0

Hello,
I created a sharepoint application that exposes a wcf service but when I consume it via console application that runs on the same machine I get the following error:

System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme ‘Anonymous’.
The authentication header received from the server was ‘NTLM’. —> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Ā Ā  at System.Net.HttpWebRequest.GetResponse()
Ā Ā  at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Ā Ā  — End of inner exception stack trace —

Server stack trace:
Ā Ā  at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)
Ā Ā  at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
Ā Ā  at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Ā Ā  at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
Ā Ā  at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
Ā Ā  at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
Ā Ā  at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
Ā Ā  at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
Ā Ā  at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
Ā Ā  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
Ā Ā  at WcfTestClient.ActioDev.IServiceWF.PingService()
Ā Ā  at WcfTestClient.ActioDev.ServiceWFClient.PingService()
Ā Ā  at WcfTestClient.Program.ActioDev()

Ā It works fine if the domain credentials are set as follows in the client:

var wCred = client.ClientCredentials.Windows.ClientCredential;
Ā Ā  wCred.Domain = domain;
Ā Ā  wCred.UserName = userName;
Ā Ā  wCred.Password = password;

but iI would like to remove the authentication so that the service is accessible to everyone.
I would appreciate it very much if someone showed me how to do it.

Thanks in advance.

ste22

Client app.config:

<system.serviceModel>
Ā Ā  <bindings>
Ā Ā Ā Ā Ā  <basicHttpBinding>
Ā Ā Ā Ā Ā Ā Ā Ā  <binding name=”Std” />
Ā Ā Ā Ā Ā  </basicHttpBinding>
Ā Ā  </bindings>
Ā Ā  <client>
Ā Ā Ā Ā Ā  <endpoint address=”http://localhost/_vti_bin/ServiceWF/servicewf.svc”Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā 
binding=”basicHttpBinding” bindingConfiguration=”Std” contract=”ActioDev.IServiceWF” name=”ActioDev” />

Ā Ā  </client>
</system.serviceModel>

Host service:

[BasicHttpBindingServiceMetadataExchangeEndpoint]
Ā Ā Ā  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
Ā Ā Ā  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
Ā Ā Ā  public class ServiceWF : IServiceWF
Ā Ā Ā  {
Ā Ā Ā Ā Ā Ā  public string PingService()
Ā Ā Ā Ā Ā Ā  {
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  return “OK”;
Ā Ā Ā Ā Ā Ā  }
Ā Ā Ā  }

Ā Ā Ā  [ServiceContract(Namespace = “OW.WIO.ServiceWF.Operations”)]
Ā Ā Ā  public interface IServiceWF
Ā Ā Ā  {
Ā Ā Ā Ā Ā Ā  [OperationContract]
Ā Ā Ā Ā Ā Ā Ā  string PingService();
Ā Ā Ā  }


(Visited 274 times, 1 visits today)
Chanakya Jayabalan Answered question April 25, 2018
Add a Comment