Hi I have a c# client application trying to connect to a WCF web service. The configuration for the bindings is in the app.config file of the client.
When I call to instatiate the web service (which is an https connection) I get the following error.
Exception Details:
System.InvalidOperationException: Could not find default endpoint element that references contract 'TcWcfServices.ITcWcfService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at xx.Int.Biz.Services.TMOScheduling.TcWcfServices.TcWcfServiceClient..ctor()
My code simple calls
if (_wcfClient == null)
_wcfClient = new TcWcfServiceClient();
In my TMOSAcheduling.exe.config file I have this snippet to try and bind to the WCF service.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_ITcWcfService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="33554432" maxBufferPoolSize="524288" maxReceivedMessageSize="33554432"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="999999999" maxStringContentLength="999999999"
maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
<security mode="Transport">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm=""/>
<message clientCredentialType="UserName"
algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<!-- If Environment is HTTPS then use below client and comment out HTTP Client-->
<!-- HTTPS Client -->
<client>
<endpoint address="https://xyz.externalhttpsAddredd.net/TcWcfServices/TcWcfServices.svc"
behaviorConfiguration="TcWcfServicesBehavior"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpsBinding_ITcWcfService"
contract="TcWfcServices.ITcWcfService"
name="BasicHttpsBinding_ITcWcfService" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="TcWcfServicesBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
I wondered if anyone could give me some suggestion of what the issue would be or how i might go about adding the HTTPS binding so I can instantiate and call the service.
This config file had to be "hand generated" as I was developing against a service with the same name that was not HTTPS and was also sitting on my localhost development webservice site.
Also, this client app can not run on my dev. machine because I can not reach the server URL from the dev. machine
Thanks! I am kind of at a crunch time to get this implemented and have tried everything I can think of with similar results.
EDIT HERE IS THE SECOND CONFIG FILE
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_ITcWcfService"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="33554432" maxBufferPoolSize="524288" maxReceivedMessageSize="33554432"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="999999999" maxStringContentLength="999999999"
maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
<security mode="Transport">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm=""/>
<message clientCredentialType="UserName"
algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxxxxx.testexternal.net/TcWcfServices/TcWcfServices.svc"
behaviorConfiguration="TcWcfServicesBehavior"
binding="basicHttpBinding"
contract="TcWfcServices.ITcWcfService" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="TcWcfServicesBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
Second edit. This worked but had certificate errors due to the https
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITcWcfService"
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="Transport">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://txxxx.external.net/TcWcfServices/TcWcfServices.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ITcWcfService"
contract="TcWcfServices.ITcWcfService"
name="BasicHttpBinding_ITcWcfService" />
</client>
</system.serviceModel>
The problem is that your <endpoing> element has a name attribute defined, so you either need to remove it to make it the "default endpoint" for that contract, or specify the endpoint name manually in the constructor of the client proxy object.
From the documentation at http://msdn.microsoft.com/en-us/library/ms731762(v=vs.110).aspx
Optional string attribute. This attribute uniquely identifies an
endpoint for a given contract. You can define multiple clients for a
given Contract type. Each definition must be differentiated by a
unique configuration name. If this attribute is omitted, the
corresponding endpoint is used as the default endpoint associated with
the specified Contract type. The default is an empty string.
the answer ended up being the last edit i made but I also ended up having a cert Issue (another thing all together). So we also ended up going to HTTP instead.
Tomasr - your suggestions were at least helpful in pointing me at some things I did not know about endpoints and the like. And I was able to verify that I was in fact using the correct config - something I was second guessing myself.
Related
I have a WPF/WCF application in which I have used external web service by referring .asmx URL in my solution's Service References folder.
At server side, I have created entries in web.config as below:
<binding name="ExtractService"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="2147483647" maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<client>
<endpoint name="ExtractService"
address="https://example.com/DataExtractService.asmx"
binding="basicHttpBinding" bindingConfiguration="ExtractService"
contract="ExtractService" />
</client>
Also I have an app.config entry at client side same as web.config above.
Everything works fine when I run it in development environment. Maybe because my client and web server (WCF) are on the same machine.
But when I deploy the app on my test server, it starts giving below error. The client is on my machine and the server (WCF) is on other machine in this case.
Message: HandlingInstanceID: 71a85aef-dbb0-4c28-9035-57f8b7526ee0
An exception of type 'System.ServiceModel.EndpointNotFoundException' occurred and was caught.
There was no endpoint listening at https://example.com/DataExtractService.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
To solve this, I tried to copy the same configuration in app.exe.config file at client side, but it does not work.
Where am I missing the client configuration? I also copied the app.config in server's bin folder, but did not help.
The server side should contain a section <services> that defines what services are available at which endpoints on this server (there has to be at least ONE <service> subsection, which defines at least ONE endpoint where this service is available at - could be multiple, too).
The client side should then contain a section <client> that connects to one of those available endpoints.
Or in brief: if you have no section <services> in your server-side config, then you have not exposed any endpoints to connect thus, thus leading to this error.
So your server-side config ought to look something like this:
<!-- Behavior is optional - maybe you need to define something, maybe not -->
<behaviors>
<serviceBehaviors>
<behavior name="ExtractServiceBehavior">
.....
</behavior>
</serviceBehaviors>
</behaviors>
<!-- Binding is the same as defined on the client -->
<binding name="ExtractService" ....
......
</binding>
<!-- Define all your services that you offer -->
<services>
<service name="ExtractService"
behaviorConfiguration="ExtractServiceBehavior">
<endpoint name="ExtractService"
address="https://example.com/DataExtractService.asmx"
binding="basicHttpBinding"
bindingConfiguration="ExtractService"
contract="IExtractService" />
</service>
</services>
Also: typically, your contract should be an interface (IExtractService) - not a concrete class that implements that interface.
I have been beating my head against this for two days and tried a number of things to try to get this to work to no avail. I'm trying to get this system to work on my local machine for debugging purposes. I'm hoping somebody here can see something that I've become blind to, or can offer some sort of advice.
I have two wcf services (actually 4, but more on that later). One is a SOAP webservice running on IIS. The webservice is trying to make a call to the other service (the agent). In the production environment, there are two firewalls between the two services. They use net.tcp protocol with certificate security to connect.
We use self-signed certificates for development and qa purposes.
I have the client and service certificates installed and have granted the app pool read access to the certificates.
I have verified that Net.Tcp Port Sharing Service, Net.Tcp Listener Adapter, Net.Pipe Listener Adapter are all running.
net.tcp protocal is enabled and net.tcp binding is defined in IIS.
The firewall is off.
Both services connect to an Identity Management service (IMS) which is also a WCF service running on a qa server, not my local machine. The webservice is able to successfully connect to the IMS service. I'm trying to use the same binding to connect to the agent service. As far as I can tell the address, binding and contract are all matching between the webservice and the agent, yet I still get the EndPointNotFoundException. What have I missed?
Here is the system.serviceModel section from the web.config for the webservice:
<system.serviceModel>
<client>
<endpoint address="net.tcp://localhost:8102/Acord/201307" behaviorConfiguration="NetTcpCertificatesBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" contract="AcordContract.IAcordService201307" name="AcordCertificateEndpoint">
<identity>
<certificateReference findValue="(value redacted)" isChainIncluded="false" storeLocation="LocalMachine" x509FindType="FindByThumbprint" />
<dns value="localhost" />
</identity>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="NetTcpCertificatesBehavior">
<clientCredentials>
<clientCertificate findValue="(value redacted)" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
<serviceCertificate>
<authentication certificateValidationMode="None" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="NetTcpCertificatesBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security>
<transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign" />
</security>
</binding>
<binding name="NetTcpMessageCertificatesBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="100" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<message clientCredentialType="Certificate" />
</security>
</binding>
<binding name="NetTcpWindowsBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:10:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard"
listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="65535" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
<binding name="NetTcpMessageWindowsBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="100" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
Here is the system.serviceModel section from the app.config for the agent service:
<system.serviceModel>
<diagnostics performanceCounters="Default"/>
<bindings>
<netTcpBinding>
<binding name="NetTcpWindowsBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:10:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard"
listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="65535" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
<binding name="NetTcpCertificatesBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" sendTimeout="00:10:00" portSharingEnabled="true">
<security>
<transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/>
</security>
</binding>
<binding name="NetTcpMessageWindowsBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="100" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="AcordAgent.AcordService" behaviorConfiguration="AcordServiceBehavior">
<endpoint address="http://qaschedapp:8100/Acord" binding="webHttpBinding" behaviorConfiguration="HttpWebGetBehavior" contract="AcordContract.IMeta" name="MetaEndpoint">
<!--the name of this endpoint above (MetaEndpoint) must stay-->
</endpoint>
<!--binding for clients within the firewall calling from C# with WCF -->
<endpoint address="net.tcp://localhost:8101/Acord/201307" binding="netTcpBinding" bindingConfiguration="NetTcpMessageWindowsBinding" name="NetTcpWindowsEndpoint" contract="AcordContract.IAcordService201307">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!--binding for clients outside the firewall calling from C# with WCF using certs -->
<endpoint address="net.tcp://localhost:8102/Acord/201307" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" name="NetTcpCertificatesEndpoint" contract="AcordContract.IAcordService201307">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8102/Acord/mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="NetTcpCertificatesBehavior">
<clientCredentials>
<clientCertificate findValue="(value redacted)" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
<serviceCertificate>
<authentication certificateValidationMode="None"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AcordServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<serviceCertificate findValue="(value redacted)" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
<clientCertificate>
<certificate findValue="(value redacted)" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
Addendum: I have just run netstat -a and I don't see anything listening on port 8102. So clearly that is why I'm getting the response I am getting. The question I have now is, why is the agent not listening on 8102? I have the agent service running in Visual Studio 2015 with break points set. Do I need to install the service and then attach to the process?
Well, the problem was that there is an appSetting in this application's config file that controls whether the servicehost gets created or not and the setting was set to false. I can't say why there is such a setting in the config file. Setting the appSetting to true, however, has simply revealed a whole new problem. So, on to the next problem.
This is the first time im doing this and have come accross an issue. I think im nearly there but I need help from the gods!, (thats you guys !).
I have a web service (WCF) that works great. I now need to add an SSL certificate to this. I have installed the SSL certificate onto IIS and binded it to the web service.
I have also added the following into my web.config
<endpoint address="" behaviorConfiguration="WebBehavior" binding="webHttpBinding" contract="MyWebService.IService1" />
<endpoint address="https://myDomain.co.uk/Service1.svc" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="MyWebService.IService1">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="CertName" />
</identity>
I also have the following bindings
<binding name="secureHttpBinding" allowCookies="true">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding" />
<add scheme="https" binding="basicHttpBinding" />
</protocolMapping>
My Issue is when I call the web service as HTTP its fine,
When I call it as HTTPS I am getting a 403 error. Im not sure what the issue is.
Help Please
Thanks in Advance
Alpesh
I found the answer.
First, the end point should only be the following. I removed the other end porint
<endpoint address="" behaviorConfiguration="WebBehavior" binding="webHttpBinding" bindingConfiguration="secureHttpBinding" contract="MyWebService.IService1" />
The binding should be
<webHttpBinding>
<binding name="secureHttpBinding" allowCookies="true">
<security mode="Transport" />
</binding>
</webHttpBinding>
I removed the the following line
<transport clientCredentialType="Certificate" />
This solved my issue. i hope this helps others. Thanks
I've been given a Web Service (ASMX) to consume witch I need to use Windows credentials for.
So, I have set up my client VPN and called the WSDL, saved as an XML file and generated the proxy class using the svcutil.exe, so far, so good...
I'm calling the service as
// Web Service
client = new CmListSync.Models.WebCorePlayersSoapClient();
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(cUser, cPass, cDoma);
and in the web.config I have this setup:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WebCorePlayersSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" algorithmSuite="Default" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://vm-wssrv01/players.asmx" binding="wsHttpBinding"
bindingConfiguration="WebCorePlayersSoap" contract="WebCorePlayersSoap"
name="WebCorePlayersSoap" />
</client>
</system.serviceModel>
but when I try to call the service I get an exception saying:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm=\"vm-wssrv01\"'.
What am I missing? shouldn't the service authenticate normally as I have provided the windows credentials? What more should I do?
What I have tried:
set the security mode to Message and I got the same error as in the question above
set the security mode to TransportWithMessageCredential I got: The
provided URI scheme 'http' is invalid; expected 'https'.\r\nParameter
name: via
set the security mode to Transport and I got: Binding validation failed because the WSHttpBinding does not support reliable sessions over transport security (HTTPS). The channel factory or service host could not be opened. Use message security for secure reliable messaging over HTTP.
From John Saunders comment:
I have switched to basicHttpBinding
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WebCorePlayersSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" realm="vm-wssrv01" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://vm-wssrv01/players.asmx" binding="basicHttpBinding"
bindingConfiguration="WebCorePlayersSoap" contract="WebCorePlayersSoap"
name="WebCorePlayersSoap" />
</client>
</system.serviceModel>
and tried changing the security mode to:
TransportWithMessageCredential
{"The provided URI scheme 'http' is invalid; expected 'https'.\r\nParameter name: via"}
TransportCredentialOnly
{"The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Basic realm=\"vm-wssrv01\"'."}
Message
{"BasicHttp binding requires that BasicHttpBinding.Security.Message.ClientCredentialType be equivalent to the BasicHttpMessageCredentialType.Certificate credential type for secure messages. Select Transport or TransportWithMessageCredential security for UserName credentials."}
Transport
{"The provided URI scheme 'http' is invalid; expected 'https'.\r\nParameter name: via"}
None
{"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm=\"vm-wssrv01\"'."}
I'm running out of ideas :(
The service is HTTP only, not HTTPS and I have no Certificate to use...
after 3 days, and with a big help from John Saunders as he stated that the only possible binding for an ASMX service would be basicHttpBinding (my search for an answer started to be much more focused) I got into this:
In the service caller, one must use the client.ClientCredentials.UserName as:
// Web Service
client = new CmListSync.Models.WebCorePlayersSoapClient();
client.ClientCredentials.UserName.UserName = cUser;
client.ClientCredentials.UserName.Password = cPass;
and in the configuration part, one needs to use:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WebCorePlayersSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://vm-wssrv01/players.asmx" binding="basicHttpBinding"
bindingConfiguration="WebCorePlayersSoap" contract="WebCorePlayersSoap"
name="WebCorePlayersSoap">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
I have two custom web services built on top of SharePoint. We switched servers and upgraded the site from 2008 to 2010 over the weekend. I now get the following errors on each web service when viewed through the .NET web service wrapper.
System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'. ---> System.Net.WebException: The remote server returned an error: (401)
and
System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
The web services have dlls that live in the GAC and the ASMX files live in the LAYOUTS hive folder. These worked fine before the upgrade/server move.
What I think is happening is that the default windows credentials aren't being passed to the service. My web service calls SharePoint web services to get list content.
Here's an example of one of the calls that returns a 401:
<WebMethod()> _
Public Function TestGetUserInfo() As String
Dim userService As New SharepointUser.UserGroup
userService.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim UserInfoXML As XmlNode = userService.GetUserInfo(User.Identity.Name)
Return UserInfoXML.ChildNodes(0).Attributes("Name").Value
End Function
This call goes against: http://{DomainName}/_vti_bin/Lists.asmx?wsdl
I've verified that user.identity.name returns the correct logged in user info. I think it's the system.net.credentialcahche.defaultcredentials that's not working. I've also tried .defaultnetworkcredentials with no luck.
This is what I have in the web.config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="projectBasicHttpConf" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" maxBufferSize="4194304" maxReceivedMessageSize="500000000" messageEncoding="Text" transferMode="StreamedResponse">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="BasicHttpBindingWithWindowsAuthentication">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="SPFilesAccessServiceSoap" 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="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="clientEndPointBehavior">
<clientCredentials>
<windows allowedImpersonationLevel="Impersonation" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
Under system.web:
<authentication mode="Windows" />
<identity impersonate="true" />
I've gone back and forth with anonymous authentication with no luck.
In IIS I have windows authentication enabled and NTLM as my provider.
Any ideas on how to fix this? Thanks so much for reading.
-Nate
I never figured it out. I did a workaround where I called the Microsoft.Sharepoint namespace stuff directly instead of calling a web service. That bypassed the security issues.
all u need to pass from the client is System.Net.NetworkCredentials("Username",Password","Domain");
It should solve the problem I guess.
Since you solved this with using the server object model instead of a web service call (which will only work on the server), this may be the loop back check feature causing the 401s.
Here is the MS KB- http://support.microsoft.com/kb/896861
It is recommended to use the specify hosts method instead of the disable registry setting.