I have a WCF web service, and a client both on the same machine. Accessing the WCF web service directly using the browser works, but the client can't connect; error message below. Any ideas? Integrated Windows Auth in IIS is used for both client and server.
The remote server returned an error: (401) Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[WebException: The remote server returned an error: (401) Unauthorized.]
System.Net.HttpWebRequest.GetResponse() +5313085
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +54
[MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +7594687
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +275
HRPaysService.IService1.GetAlert() +0
HRPaysService.Service1Client.GetAlert() +15
_Default.Page_Load(Object sender, EventArgs e) +138
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Client:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"
proxyCredentialType="Windows" realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://hrpaysservice/service1.svc"
binding="basicHttpBinding"
bindingConfiguration="basicBinding"
contract="HRPaysService.IService1">
</endpoint>
</client>
</system.serviceModel>
Server:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"
proxyCredentialType="Windows" realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://hrpaysservice/service1.svc"
binding="basicHttpBinding"
bindingConfiguration="basicBinding"
contract="HRPaysService.IService1">
</endpoint>
</client>
</system.serviceModel>
I encountered the same error when I tried to access a WCF service hosted on IIS through adding a "Service Reference" to my Windows Forms application. But when the client hit a call for a service method, I got "UnAuthorized 401 exception". Here is my solution to this problem:
(1) I was using [wsHttpBinding] switch it to be [basicHttpBinding] as follows in the WCF service config file:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="IService1">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpointBinding"
name="BasicHttpEndpoint" contract="IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
(2) Add a "Service Reference" from your client application and give it a name (we will use that name in the following step as "ProxyCalssName")
(3) adjust the app.config file of the client application to as follows:
<system.serviceModel>
<client>
<endpoint address="your service URL"
binding="basicHttpBinding" bindingConfiguration="basic" contract="ProxyClassName.ServiceName"
name="default" />
</client>
<bindings>
<basicHttpBinding>
<binding name="basic">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
(4) In the code behind of the client Application:
ProxyClassName.MyServiceName srv = new ProxyClassName.MyServiceName("default");
//default is the name of the endpoint in the app.config file as we did.
srv.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
Good Luck, DigitalFox
Client:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<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" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3097/Service1.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="HRPaysService.IService1"
name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Server:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="basicBehavior" name="WcfService1.Service1">
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="basicBinding" />
<endpoint address="mex" binding="basicHttpBinding" contract="IMetadataExchange" bindingConfiguration="basicBinding" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="basicBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Do you have a CrossDomain.xml document set up in your services web application? If not, create one with the following contents -
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
If the Virtual directory of WCF services is not configured for anonymous access, then the "mex" endpoint in should be removed.
You have posted 2 different sets of configs and there seems to be mismatch. Could you post the configs that is causing the error ?
Your first (top most) client config and the latest server config (without the mex part) should work.
Related
I have seriously ran into a problem and could not resolve it. I have searched a ton of forums but couldn't find anything matching to resolve my issue.
I have two components. One is a WCF service and the other is a client which is basically a hardware that fetches the information from the web service. The WCF service is hosted over IIS with https. The client was able to hit the service when the SSL certificate was not installed, but after the installation of SSL certificate the machine started giving the error I mentioned in the title of my question.
This is the web.config of my service
`
<system.serviceModel>
<!--<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />-->
<bindings>
<wsHttpBinding>
<binding name="wshttpbinding" bypassProxyOnLocal="true" receiveTimeout="00:10:00">
<reliableSession inactivityTimeout="23:00:00" enabled="true"/>
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="None" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Services.ServiceBehavior" name="CJDWebServices.Service">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wshttpbinding"
contract="CJDWebServices.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/TxService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Services.ServiceBehavior">
<!-- 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>
`
And this is the app.config of my application running on the hardware
`
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:25:00" sendTimeout="00:25:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="16384"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="23:59:00"
enabled="True" />
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
<binding name="WSHttpBinding_IMachineMgmt" closeTimeout="00:02:00"
openTimeout="00:02:00" receiveTimeout="00:25:00" sendTimeout="00:25:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="23:59:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
<binding name="WSHttpBinding_IPM" closeTimeout="00:02:00" openTimeout="00:02:00"
receiveTimeout="00:05:00" sendTimeout="00:05:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://dummy1/dummy1/dummy1.svc" binding="wsHttpBinding" <!-- This is the one causing trouble --!>
bindingConfiguration="WSHttpBinding_IService" contract="IService"
name="WSHttpBinding_IService">
<identity>
<dns value="dummy1" />
</identity>
</endpoint>
<endpoint address="https://dummy2/dummy2/dummy2.asmx" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IMachineMgmt"
contract="MonService.IMachineMgmt" name="WSHttpBinding_IMachineMgmt">
<identity>
<dns value="dummy2" />
</identity>
</endpoint>
<endpoint address="https://dummy3/dummy3/" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IPM" contract="IPM" name="WSHttpBinding_IPM">
<identity>
<dns value="dummy3" />
</identity>
</endpoint>
</client>
</system.serviceModel>
<appSettings>
<empty here>
</appSettings>
</configuration>
`
The service mentioned below is my pain area
<endpoint address="https://dummy1/dummy1/dummy1.svc" binding="wsHttpBinding" <!-- This is the one causing trouble --!>
bindingConfiguration="WSHttpBinding_IService" contract="IService"
name="WSHttpBinding_IService">
<identity>
<dns value="dummy1" />
</identity>
</endpoint>
I have tried playing around with changing the security mode from none to transport and vice versa, but no luck. I even tried it on the web service configuration file but still no luck.
The service is accessible on the machine by the URL if I browse it on the browser
In response to your problem, I propose the following two solutions:
1.First of all, in the MSDN post there is an example of using wshttpbinding transport, accompanied by the corresponding code, you can learn about it.
Here is the web.config on its server side:
<system.serviceModel>
<protocolMapping>
<add scheme="https" binding="wsHttpBinding" />
</protocolMapping>
<bindings>
<wsHttpBinding>
<!-- configure wsHttp binding with Transport security mode and clientCredentialType as None -->
<binding>
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To expose metadata over a secure transport uncomment the serviceMetadata behavior
and the mex endpoint above
Note: you must have a valid certificate for svcutil to work -->
<!--<serviceMetadata httpsGetEnabled="True"/>-->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Here is the app.config on its client side:
<system.serviceModel>
<client>
<!-- this endpoint has an https: address -->
<endpoint address="https://localhost/servicemodelsamples/service.svc" binding="wsHttpBinding" bindingConfiguration="Binding1" contract="Microsoft.Samples.TransportSecurity.ICalculator"/>
</client>
<bindings>
<wsHttpBinding>
<!-- configure wsHttpbinding with Transport security mode
and clientCredentialType as None -->
<binding name="Binding1">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
2.Finally, you can try to use custom bindings:
wcf custom bindings
The goal is to send the contents of a table as a data set to the client. I get an error from the client application:
"The maximum message size quota for incoming messages (65536) has been exceeded."
Although in the same WCF application retrieving large data amount from the client there is no error.
Please see the config file.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
<bindings>
<wsHttpBinding>
<binding name="TeansferBinding"
messageEncoding="Mtom"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"/>
<!--
For forced HTTPS
change the security mode from None to Transport and add Transport key with clientCredentialType="None"
<security mode="Transport">
<transport clientCredentialType="None"/>
</security
-->
<security mode="None" />
</binding>
<binding name="ProjectBinding"
messageEncoding="Text"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"/>
<!--
For forced HTTPS
change the security mode from None to Transport and add Transport key with clientCredentialType="None"
<security mode="Transport">
<transport clientCredentialType="None"/>
</security
-->
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="TransferBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<!-- 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"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="TransferBehavior" name="TransferServer.Restore" >
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="TeansferBinding"
contract="TransferServer.IRestore"/>
<!-- remove mex endpoint of production server -->
<endpoint address="mex"
binding="mexHttpBinding"
name="Mex"
contract="IMetadataExchange"/>
<host>
<timeouts closeTimeout="00:10:00" openTimeout="00:10:00"/>
</host>
</service>
<service behaviorConfiguration="TransferBehavior" name="TransferServer.ProjectProvider">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="ProjectBinding"
contract="TransferServer.IProjectProvider"/>
<!-- remove mex endpoint of production server -->
<endpoint address="mex"
binding="mexHttpBinding"
name="Mex"
contract="IMetadataExchange"/>
<host>
<timeouts closeTimeout="00:10:00" openTimeout="00:10:00"/>
</host>
</service>
</services>
I've searched for a solution but only come back to the adjustment of the config file. The WCF application is not reporting any error and the client is reporting the error.
I've tried using wsHttpBinding and basicHttpBinding with no success. I've tried MTOM and Text message encoding.
#Abraham Qian
App Config File for Client
Here is the App.Config file for the client.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IRestore" messageEncoding="Mtom">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="WSHttpBinding_IProjectProvider">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://myServer.com/Restore.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRestore"
contract="RestoreProvider.IRestore" name="WSHttpBinding_IRestore" />
<endpoint address="https://myServer.com/ProjectProvider.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IProjectProvider"
contract="ProjectProvider.IProjectProvider" name="WSHttpBinding_IProjectProvider" />
</client>
</system.serviceModel>
</configuration>
As for the binding information for the ProjectProvider service the only difference is "maxBufferSize" which when inserted creates an error.
Usage code in the Client
Public sub GetZips()
'Get the information from Ops
Using oProjectProvider As New ProjectProvider.ProjectProviderClient
MyDataSet = oProjectProvider.GetZipCodeData
oProjectProvider.Close()
End Using
Application.DoEvents()
End sub
I would like to know the client configuration. how do you create a call to the service? We had better apply the configuration on both the client-side and the server-side. Besides, I suspect there is something wrong with the client service endpoint address. Please post the complete client configuration.
In addition, please refer to the below configuration.
<binding maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
Feel free to let me know if the problem still exists.
I am trying to upload files using WCF. Everything under 16K works fine, but anything over throws this error:
There was an error deserializing the object of type System.Byte[]. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader
This is my WCF Service app.config
<?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>
<wsHttpBinding>
<binding name="WSHttpBinding_IRAISAPI" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600"
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 name="RAIS_WCF_Services.RAISAPI">
<endpoint address="" binding="wsHttpBinding" contract="RAIS_WCF_Services.IRAISAPI">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/RAIS_WCF_Services/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
and here is my client app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IRAISAPI" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="104857600"
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/RAIS_WCF_Services/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRAISAPI"
contract="RAIS.IRAISAPI" name="WSHttpBinding_IRAISAPI">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Any help is much appreciated! Thanks.
It doesn't look like your service is not properly referring to your binding configuration.
Search in your service config for WSHttpBinding_IRAISAPI and you'll see what I mean.
You need:
<endpoint address="" binding="wsHttpBinding"
contract="RAIS_WCF_Services.IRAISAPI"
bindingConfiguration="WSHttpBinding_IRAISAPI">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
I'm assuming that you mean the maxArrayLength setting isn't being set automatically in your client configuration after adding a service reference and/or it is getting lost after updating your client's service reference? If this is what you're experiencing, this is by design. Settings such as timeouts, maxArrayLength, etc are not exposed in WSDL and therefore cannot be pushed to the client by the service when the service reference is created/updated.
Try adding this global config to your server-side configuration. This will tie your service binding to a binding configuration.
<system.serviceModel>
<protocolMapping>
<remove scheme="http"/>
<add scheme="http" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IRAISAPI" />
</protocolMapping>
</system.serviceModel>
You can also use behaviors/serviceBehaviors/behavior/serviceMetadata/httpGetBindingConfiguration for a more localized solution.
My client keep complaining that they are receiving Timeout error but I don't see a trace file generated on my side. Can anybody tell me how to fix this?
I already increase the receiveTimeout to 15 minutes (00:15:00). I did this both on WCF service side and on the client side. My service is not a long running process, the client should receive the response in 0 - 2 minutes max.
Not only receiveTimeout and I set the all timeouts to 00:15:00, also I set the serviceThrottling (maxConcurrentCalls,maxConcurrentInstances,maxConcurrentSessions) to 200.
Note: When ever there is an Timeout error, I don't see anything related to that in Tracing.
Here is my config files,
WCF Service Config:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="150" maxRequestLength="8192" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="MYWS" name="MYDEMO.MYDEMOCLS">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="SecureBinding" name="wsDemo" contract="MYINTERFACES.ICustomer">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="wsMex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.1/Customer/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MYWS">
<serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="200" maxConcurrentSessions="200" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="SecureBinding" maxBufferPoolSize="2147483647" closeTimeout="00:15:00" openTimeout="00:15:00" receiveTimeout="00:15:00" sendTimeout="00:15:00" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Message">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
Client Config:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="150" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsDemo" closeTimeout="00:15:00" openTimeout="00:15:00" receiveTimeout="00:15:00" sendTimeout="00:15:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:15: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://192.168.0.1/DEMOSVCS/Customer.svc" binding="wsHttpBinding" bindingConfiguration="wsDemo" contract="PROJ.IFACE" name="wsDemo">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Here is a client code
DemoClient client = new DemoClient("wsDemo");
DemoResponse DemoResponse = new DemoResponse();
try
{
DemoResponse = client.CreateProduct(product);
client.Close();
return DemoResponse;
}
catch (Exception ex)
{
try
{
if (client.State == CommunicationState.Faulted)
client.Abort();
else
client.Close();
throw ex;
}
catch
{
client.Abort();
throw ex;
}
}
Thanks
Timeout errors are hard to diagnose. We've had issues that were completely related to WAN latency while passing large datasets across the wire.
However, if you find that once the timeout occurs, no further calls to the web service can be made, I would look into this WCF 3.5 & 4.0 Hotfix
I am getting this exception when trying to access a wcf web service.
[WebException: The remote server returned an error: (400) Bad Request.]
System.Net.HttpWebRequest.GetResponse() +5314029
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +54
Server Binding Information
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wcfSmartConnect" closeTimeout="10:01:00"
maxBufferSize="104857600" maxBufferPoolSize="104857600"
maxReceivedMessageSize="104857600" openTimeout="10:01:00"
receiveTimeout="10:10:00" sendTimeout="10:01:00"
messageEncoding="Mtom" transferMode="StreamedRequest">
<readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
maxArrayLength="104857600" maxBytesPerRead="104857600"
maxNameTableCharCount="104857600" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WcfSmartConnect.Service1"
behaviorConfiguration="WcfSmartConnect.Service1Behavior">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="wcfSmartConnect"
contract="WcfSmartConnect.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfSmartConnect.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Client Binding Information
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wcfSmartConnect" closeTimeout="10:01:00"
maxBufferSize="104857600" maxBufferPoolSize="104857600"
maxReceivedMessageSize="104857600" openTimeout="10:01:00"
receiveTimeout="10:10:00" sendTimeout="10:01:00"
messageEncoding="Mtom" transferMode="StreamedRequest">
<readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
maxArrayLength="104857600" maxBytesPerRead="104857600"
maxNameTableCharCount="104857600" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IService11" closeTimeout="01:00:00"
openTimeout="01:00:00" receiveTimeout="01:00:00"
sendTimeout="01:00:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="1048576000" maxReceivedMessageSize="1048576000"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
maxArrayLength="104857600" maxBytesPerRead="1048576000"
maxNameTableCharCount="104857600" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true" algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint name="WSHttpBinding_IService11"
address="http://abc.com/API/serv.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService11"
contract="SmartConnectRepublic.IService1" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint name="BasicHttpBinding_IService1"
address="http://localhost:4649/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="wcfSmartConnect"
contract="SmartConnect.IService1" />
</client>
</system.serviceModel>
Can you tell us a bit about your setup?
what binding do you use?
is this the only service method? If not: do the others work?
show us the configs on client and server! (everything inside <system.serviceModel> is of interest)
It would appear as if the client times out waiting for the server - this can be because the server takes too long to respond (if you do a lot of data loading); in that case, you need to increase your timeouts on the server and the client
Or you might be sending too large a data packet over the wire - in that case, you might also need to increase the settings for maxReceivedMessageSize et al.
#Pinu: are you trying to upload 5 MB? You have transferMode=StreamRequest, which means your request from the client to the server will be streamed.
If you're transferring 5 MB, it's a good idea to stream - which way do you transfer those bytes??