I am getting an issue with WCF service I have created. Issue is not coming on all clients - i.e. on some systems it is working others not.
Error 1:
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
Error 2:
On some system the operation contract is not exposed properly. A red symbol is coming across operation contract. And unable to call it using wcftestclient.
Config File:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" >
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="ExternalService.Service.MyDashboardService">
<host>
<baseAddresses>
<add baseAddress = "http://****/ExternalService.Service/MyDashboardService/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="ExternalService.ServiceInterface.IMyDashboardService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
Now the client config I am getting in wcftestclient for Error 1:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyDashboardService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://****/ExternalService.Service/MyDashboardService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyDashboardService"
contract="IMyDashboardService" name="BasicHttpBinding_IMyDashboardService" />
</client>
</system.serviceModel>
</configuration>
Client Config when service is working:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyDashboardService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://****/ExternalService.Service/MyDashboardService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyDashboardService"
contract="IMyDashboardService" name="BasicHttpBinding_IMyDashboardService" />
</client>
</system.serviceModel>
</configuration>
Please suggest what could be the reason for different behavior of service on different machines.
you should use same bindingConfiguration on both sides clients and service
Related
I prepared a wcf service host and configured with some binding information below.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding" closeTimeout="00:02:00" openTimeout="00:02:00"
receiveTimeout="00:20:00" sendTimeout="00:02:00" transactionFlow="true"
transferMode="Buffered" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport protectionLevel="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="tcpServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="tcpServiceBehavior" name="MyClass">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="IMyClass">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
And instantiate with the code below:
ServiceHost wcfHost = new ServiceHost(typeof(MyClass));
wcfHost.Open();
Using QuickWatch checked it out and verified the configuration values. Then, I added Service Reference on "net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" to an other project. So, the new config file below has been created in the client project.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyClass" 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="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyClass" contract="IMyClass" name="NetTcpBinding_IMyClass">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
The problem is the binding configuration of host can't come to client. If I change client configuration it doesn't affects. For example, changed maxStringContentLength value from 8192 to 2147483647, then, saw that client has been instantiated with correct config but, operated with old config. Searched "8192" in solution and found in .svcinfo files as XML scheme. How can I solve this weird situation?
Right click the service reference and "Update" the it and VS will regenerate the svcinfo files, or you could avoid this issue entirely by not using VS to create the service proxy and instead generating your own service proxy by hand (considered a best practice as far as I know). As you already noted, "Add Service Reference" is not smart enough to take all those configuration values from the service when creating a client.
I am trying to host a WCF service that supports wshttpbinding and wsDualHttpBinding. The reason is for desktop clients I need duplex contract and for web clients I don't.
I tried to create a contract for duplex and it work perfect, Now I tried to add new contract to my WCF which have no call back, I define new interface, add the [ServiceContract], and new class who implement the new interface contract, but I don't know how to define the web.config to let me get both binding/contract in same WCF.
here what I tried to do:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IBridgeWCFService" closeTimeout="01:01:00" openTimeout="01:01:00" receiveTimeout="01:10:00" sendTimeout="01:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="256" maxStringContentLength="2147483646" maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<reliableSession ordered="true" inactivityTimeout="01:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IWebBridgeWCFService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483646" maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646"/>
<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="BridgeNameSpace.Service1Behavior" name="BridgeNameSpace.BridgeWCFService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IBridgeWCFService" contract="BridgeNameSpace.IBridgeWCFService">
<identity>
<servicePrincipalName value="BridgeWCFService" />
<dns value="win-j7da0dqoajj" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWebBridgeWCFService" contract="BridgeNameSpace.IWebBridgeWCFService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BridgeNameSpace.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<!-- 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>
<system.web>
<compilation debug="true" />
</system.web>
</configuration>
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.
I have the following config for my WCF service:
<system.serviceModel>
<services>
<service behaviorConfiguration="After.BehaviourConfig" name="ServiceInstancingDemo.Service1">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="After.BindingConfig"
name="After.ConfigName" contract="ServiceInstancingDemo.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://rb-t510/NGCInstancing/Service1.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="After.BindingConfig" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferPoolSize="524288111" maxReceivedMessageSize="524288111" allowCookies="false">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="After.BehaviourConfig">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentCalls="30" maxConcurrentInstances="2147483647" maxConcurrentSessions="30" />
</behavior>
</serviceBehaviors>
</behaviors>
I am able to call the service with the following client code:
NGC.Service1Client ngc = new NGC.Service1Client();
var taskA = Task<string>.Factory.StartNew(() => ngc.WaitThenReturnString(5));
this.listBox1.Items.Add(taskA.Result);
The config for the client that calls the service is as follows:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Before" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferPoolSize="524288111"
maxReceivedMessageSize="524288111" allowCookies="false" />
<binding name="After" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferPoolSize="524288111"
maxReceivedMessageSize="524288111" allowCookies="false">
<security mode="None" />
</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="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://rb-t510/NGCInstancing/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="Before" contract="NGCInstance.IService1"
name="Before" />
<endpoint address="http://rb-t510/NGCInstancing/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="After" contract="NGCInstance.IService1"
name="After" />
<endpoint address="http://rb-t510/NGCInstancing/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="NGC.IService1" name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Problem is, I want to add another endpoint that will execute the same functionality but with a different behavior. To do this, I think I'm going to need to pass a string of the enpointConfigurationName to the constructor in the line=new NGC.Service1Client. I don't know what string I need to pass - I would have expected it to be the endpoint configuration name "After.ConfigName" but I tried this and got the following error message:
Could not find endpoint element with name 'After.ConfigName' and contract 'NGC.IService1' 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 name could be found in the client element.
Can anyone please help?
You would pass the value of the name attribute of the corresponding client endpoint you would like to use. For example if you wanted to use the third endpoint:
new NGC.Service1Client("WSHttpBinding_IService1")
I have a WCF Service being hosted on IIS 5.1 with Anonymous access disabled. Below is a part of the web.config file showing how the service is configured:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingCfg">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="HelloService">
<endpoint name="BasicHttpEndpoint"
address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingCfg"
contract="IHelloService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Every time I call any operations that this service exposes from a desktop application, I receive the following error message:
Either a required impersonation level was not provided, or the
provided impersonation level is invalid.
Please note that binding type and hosting environment is pre-determined by the client and cannot be changed.
Any help that may lead to resolving this issue would be greatly appreciated.
Thanks!
Zen
EDIT: Here is how the client is configured:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpoint" 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 name="BasicHttpEndpoint"
address="http://vm00000033871b.intra.pri/WCFServiceBasicHttp/HelloService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpoint"
contract="Proxy.IHelloService" />
</client>
</system.serviceModel>
Try this to pass the current users Windows credentials:
Using proxy As New PRX.HelloServiceClient()
proxy.ClientCredentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Impersonation
proxy.ChannelFactory.Credentials.Windows.ClientCredential =
CredentialCache.DefaultNetworkCredentials
Dim message As String = proxy.Hello("Hi")
MessageBox.Show(message)
End Using