I have been struggling with this problem, read many questions, articles but could not solve it. so here I am.
Webservice is within a website and I access it from a Console application [testing]. here is my Web.Config code
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Services.CilsDataReceiveBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="WindowsAuth">
<security mode="TransportCredentialOnly" >
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Services.CilsDataReceiveBehavior" name="Services.CilsDataReceive">
<endpoint address="" binding="basicHttpBinding" name="BasicHttpEndpoint" bindingConfiguration="WindowsAuth" contract="Services.ICilsDataReceive" />
<endpoint address="mex" binding="webHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Below is my code and app.config used in Console application.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICilsDataReceive" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://wgb01wa7002.worldwide.co.uk:44001/Services/CilsDataReceive.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICilsDataReceive"
contract="ICilsDataReceive" name="BasicHttpBinding_ICilsDataReceive" />
</client>
</system.serviceModel>
Below is the cs code
icDateList.titlesField = titles.ToArray();
var cilsDataReceiveClient = new CilsDataReceiveClient();
try
{
cilsDataReceiveClient.RecieveICDateList(icDateList);
Console.WriteLine(" O_O Service saved the data O_O");
}
catch (Exception exception)
{
cilsDataReceiveClient.Abort();
Console.WriteLine(exception.Message);
throw;
}
finally
{
Console.Read();
}
error message is
“The HTTP request is unauthorized with client authentication scheme ‘Anonymous’. The authentication header received from the server was ‘Negotiate,NTLM’.”
If a change my Console application app.config to
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
I get below error
“‘http://wgb01wa7002.worldwide.co.uk:44001/Services/CilsDataReceive.svc’ could not be activated. See the server’s diagnostic trace logs for more information.”
I tried many things tries WsHttpBinding but i think that uses Https rather http.
Could you please suggest something?
Edit: if I access it from browser I get “Security settings for this service require ‘Anonymous’ Authentication but it is not enabled for the IIS application that hosts this service.”
Edit 2: i tried with netTCPBinding and error changed “The provided URI scheme ‘http’ is invalid; expected ‘https’. It seems I should not use it.
Parameter name: via”
Edit 3: I tried with wsHttpBinding and still i am getting errors. its like never ending errors.
First, is your desktop environment set up to test ssl? if not, add it.
second, your likely missing WsHttpsBinding