I've looked at a number of similar topics on SO, but haven't found one that helps with this.
Have a WCF service that takes in XML to process. The XML file I'm reading from is ~600K.
The call works for small xml files (most of the time), but on the larger files I get the error:
System.ServiceModel.Security.MessageSecurityException:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
where the inner exception is:
System.ServiceModel.FaultException:
The message could not be processed. This is most likely because the action 'http://tempuri.org/ISapListener/ProcessSapRoles' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
Like I say... it works for small files, and my open, send, receive, close, and inactivity timeouts are all set to 10 minutes. It fails in about 20-30 seconds.
Also, the clock on the server and client are perfectly in sync (I've seen that posted as an answer).
My config files as they currently stand (I've played with a lot of settings):
Server:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_Custom" closeTimeout="00:00:10"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false"
maxReceivedMessageSize="1024768"
maxBufferPoolSize="1024768" >
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="CSA.GS3.Services.SapListenerBehavior"
name="CSA.GS3.Services.SapListener">
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding_Custom"
contract="CSA.GS3.Services.ISapListener">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CSA.GS3.Services.SapListenerBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Client:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ISapListener1"
closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false"
maxBufferPoolSize="1024768"
maxReceivedMessageSize="1024768">
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://gs3-test.us.tycoelectronics.com/SapListener/SapListener.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISapListener1"
contract="Gs3TestSapListener.ISapListener"
name="WSHttpBinding_ISapListener1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
I do have tracing enabled on the service, but I can't make sense out of the log files.
Other exceptions I've received while playing with the config settings:
System.ServiceModel.Security.SecurityNegotiationException
Secure channel cannot be opened because security negotiation with the remote endpoint has failed.
and
System.ServiceModel.ServiceActivationException
The requested service, 'http://../SapListener.svc' could not be activated.
If you think being able to make sense out of log files will help here, use svcTraceViewer. Just make sure you've actually set up tracing correctly. I have an article on my blog about this.
svcTraveViewer Debugging WCF Services
As regards large payloads, you may want to take a look at this MSDN article.
http://msdn.microsoft.com/en-us/library/ms733742.aspx
In particular Streaming Data.
System.ServiceModel.ServiceActivationException
The requested service, 'http://../SapListener.svc' could not be activated.
This could be a compilation error ou invalid configuration.
Is it WCF 4.0? Then you could remove your custom configuration and use automatic bindings. I also suggest you to try a binding other than wsHttpBinding, like basicHttpBinding.
I was able to get this to work with the following configuration:
Server:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_Custom"
closeTimeout="00:10:00"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxReceivedMessageSize="2097152"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2097152" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
Client:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ISapListener1" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2097152"
maxReceivedMessageSize="2097152"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
The only difference I can see is that I bumped up the maxReceivedMessageSize and maxBufferPoolSize... maybe I'm missing something else? If that was the issue, then the problem was that my overhead for the call was adding an additional 400+K to the 600K xml data I was sending
If possible and acceptable to client, you can break down the file into smaller chunks and send across, provided you don't have digital certificate etc and sorting options at client side.
Related
I have a published WCF Service running correctly and verified by pulling up the wsdl? screen.
However, when I try to access any methods using code from a separate website I get the following error:
Service 'wcfServiceFromCaps.AgentWebAppServiceClient' has zero application(non- infrastructure) endpoints. This might be because no configuration file was found for your application
[ServiceContract]
interface IAgentWebAppService
{
[OperationContract]
[FaultContract(typeof(ServiceData))]
void DoWork();
[OperationContract]
[FaultContract(typeof(ServiceData))]
String GetAgentPicURLUsingStation(string station);
}
Client WebConfig
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IAgentWebAppService" 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="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://myfulladdresshere:87/AgentWebAppService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAgentWebAppService"
contract="IAgentWebAppService" name="WSHttpBinding_IAgentWebAppService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Client CS
AgentWebAppServiceClient newWcf = new AgentWebAppServiceClient();
try
{
string newstring = newWcf.GetAgentPicURLUsingStation(this.Phone);
newpicurl = newstring;
}
catch (FaultException<wcfServiceFromCaps.ServiceData> Fex)
{
....
}
What am I missing?
Update!**
I resolved it by cleaning everything up and recreating from scratch.
Now I'm getting the following message:
Cannot open Database "dbname" requested by the login. The login
failed. Login failed for user "Servername$"
Basically, I have a finished program that connects to a Console application which hosts multiple services . What I need to do is have my clients on one PC , and my host on another hosting all the services. However I'm not sure how that would work.
At the minute my Host's config file is
<
?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IReportService" 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>
<binding name="BasicHttpBinding_IFuelSupplyService" 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>
<wsHttpBinding>
<binding name="WSHttpBinding_IPostoPumpService" 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="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
<binding name="WSHttpBinding_IService1" 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="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/PumptoPosService/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPostoPumpService"
contract="PumpPosClient.IPostoPumpService" name="WSHttpBinding_IPostoPumpService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:8732/Design_Time_Addresses/ServerService/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="Server.IService1" name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://08346.net.dcs.hull.ac.uk/services/ReportService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReportService"
contract="ReportServer.IReportService" name="BasicHttpBinding_IReportService" />
<endpoint address="http://08346.net.dcs.hull.ac.uk/services/FuelSupplyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFuelSupplyService"
contract="PricingServer.IFuelSupplyService" name="BasicHttpBinding_IFuelSupplyService" />
</client>
<services>
<service name="PumptoPosService.PostoPumpService">
<endpoint address="" binding="wsHttpBinding" contract="PumptoPosService.IPostoPumpService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/PumptoPosService/Service1/" />
</baseAddresses>
</host>
</service>
<service name="ServerService.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/ServerService/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding" contract="ServerService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Any Ideas? If possible, is there a way to have it configurable at Runtime, so if it was local, use localhost, else connect to a host on port 5000
thanks
You'll need to write a custom ServiceHostFactory. This will allow you to inject the service endpoint addresses (and ports) when the service is instantiated. This good blog post describes in detail what you would need to do.
I have a WCF service that is hosted locally. My web.config looks like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_INavigationService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="6553600" maxBufferPoolSize="5242880" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WebServices/NavigationService.svc/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INavigationService"
contract="NavigationService.INavigationService" name="BasicHttpBinding_INavigationService" />
</client>
</system.serviceModel>
My service works fine if I pass in less then 8K of text. Anything more and I get the following error:
Sys.WebForms.PageRequestManagerServerErrorException: The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'UpdateSiteMap'. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 75, position 166
Can someone tell me how to increase the text quota? As you can see, I have it set to maximum integer size.
EDIT
After Tim's suggestion, here is my new Web.Config file:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="6553600" maxBufferPoolSize="5242880" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WebServices/NavigationService.svc/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INavigationService"
contract="NavigationService.INavigationService" name="BasicHttpBinding_INavigationService" />
</client>
<services>
<service name="Navigation.INavigationService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_INavigationService"
contract="NavigationService.INavigationService" />
</service>
</services>
Based on the error message and your description of the issue, you need to ensure that you have the same settings for your service, referencing the same defined binding in the bindingConfig attirbute of the endpoint element:
<system.serviceModel>
<services>
<service name="Navigation.INavigationService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_INavigationService"
contract="NavigationService.INavigationService" />
</service>
</services>
</system.serviceModel>
If you're using .NET 4.0 and have not specified the service element, then you are using a default endpoint and default binding (which means your limited to 8192 for maxStringContentLength). The easiest way to overcome this is to remove the name attribute from the binding section of your config - .NET will then use your definition as the default binding. For example:
<binding closeTimeout="00:01:00" ....
Note no name attribute is set.
You may need to use option 1 in this case, or create a similar binding definition with no name, as I'm not 100% sure that default bindings are used for the clients; they definitely are for the service.
See A Developer's Introduction to Windows Communication Foundation 4 for more information on default bindings and endpoints.
Additional Answer Based On Edit
Try this:
<client>
<endpoint address="http://localhost/WebServices/NavigationService.svc/"
binding="basicHttpBinding"
contract="NavigationService.INavigationService"
name="BasicHttpBinding_INavigationService" />
</client>
Delete the <services> section as the default endpoint mechanism for WCF 4.0 will handle that for you, and delete the bindingConfiguration attribute from the client endpoint.
I'm working with N-tier architecture. I have a WCF service in a hosting layer. I added services file successfully in here.
Problem is when I add the service in an application. It adds the service to the project successfully, but when I call the service I can't call it from my application class but when I rebuild project I haven't any issue.
On the other hand if I add the same service to another project I haven't a problem and everything is ok.
Has anyone encountered this?
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService" 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="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:5555/MyService.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IMyService" contract="ServiceReference1.IMyService"
name="WSHttpBinding_IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
I'm trying to consume a Service with an WCF Console Application. But the only thing I get as a Response is "The remote server returned an unexpected response: (400) Bad Request."
The Service is configured with the following options:
<services>
<service name="TryOut.BasicService" behaviorConfiguration="NicksBasicBehavior">
<host>
<baseAddresses>
<add baseAddress="http://192.168.10.67:8000/Service" />
</baseAddresses>
</host>
<endpoint address ="http://192.168.10.67:8000/Service"
name="NicksEndpoint"
binding="basicHttpBinding"
contract="TryOut.IBasicService"
bindingConfiguration="BasicBinding"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="NicksBasicBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<binding name="BasicBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
The configuration file of my Client is the following:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NicksEndpoint" 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>
<client>
<endpoint address="http://192.168.10.67:8000/Service" binding="basicHttpBinding"
bindingConfiguration="NicksEndpoint" contract="ServiceReference1.IBasicService"
name="NicksEndpoint" />
</client>
Now everything works fine when I'm starting the client on the same PC as the service. But if I'm try to running the Client on a machine which is not in the domain of the server PC then I get an error, although I provide the Login information's in the client code:
c.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Nick", "password", "mydomain");
Does anybody got an idea what I'm doing wrong and how can I fix it? Thanking you in anticipation!
According to this article on MSDN, it looks as if you need to specify your credentials differently:
WCFTestService.Service myService = new WCFTestService.Service();
myService.Credentials = System.Net.CredentialCache.DefaultCredentials;
MessageBox.Show(myService.GetData(123, true));
myService.Dispose();
Could you try to use this code and try to pass the Windows credentials into myService.Credentials ? Does that work?
Marc
have you tried specifing the userPrincipalName in the identity element on your clients endpoint?