I currently have a WCF service with webHttp bindings, im attempting to increase the max size that can be inputted to the service by overriding the default settings in config, i have tried doing something like
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webHttp" >
<security mode="Transport">
<transport clientCredentialType =
"None"
proxyCredentialType="None"
realm="string" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="PrimeStreamInfoServices.Service1" behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" contract="PrimeStreamInfoServices.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.
-->
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PrimeStreamInfoServices.Service1Behavior">
<!-- 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>
<diagnostics>
and setting various other properties pertaining to message size but none seems to be working, can one even change the m essage size of a webHttp binding?
Any suggestions? Thanks!
There's a multitude of settings that might have an influence depending on your settings - try this:
<bindings>
<webHttpBinding>
<binding name="LargeWeb"
maxBufferPoolSize="1500000"
maxReceivedMessageSize="1500000"
maxBufferSize="1500000">
<readerQuotas
maxArrayLength="656000"
maxBytesPerRead="656000"
maxDepth="32"
maxNameTableCharCount="656000"
maxStringContentLength="656000"
/>
</binding>
</webHttpBinding>
</bindings>
By defining your "version" of the webHttpBinding and setting all those parameters to higher values, you should be able to get through any message size (almost).
Mind you: this does open up your system to the potential of being flooded with huge messages and thus be brought down to its knees (classic denial-of-service attacks) - that's the reason these limits are set fairly low - by design and on purpose.
You can change them to higher values - just be aware what you're doing and what the security risks are, if you do!
Marc
PS: In order to make use of these settings, you of course have to reference that binding configuration in your server and client side configs:
<client>
<endpoint address="http://localhost"
binding="webHttpBinding" bindingConfiguration="LargeWeb"
contract="IMyService" />
</client>
<services>
<service>
<endpoint address="http://localhost"
binding="webHttpBinding" bindingConfiguration="LargeWeb"
contract="IMyService" />
</service>
</services>
Setting Max Message and buffer size for WCF Rest services webhttpbinding
<bindings>
<webHttpBinding>
<binding maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
</binding>
</webHttpBinding>
</bindings>
If you are using [DataContract] decorator in your model, you need to add yhe dataContractSerializer into your web.config
Example:
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="false" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
Related
My wcf service was working until I made two changes. When I run it in debug mode I get no errors but when I deploy it to production I get the "No End Point" exception. I've followed the advise given in other posts but no change. Can anyone help me sort this out?
1. Added a method that accepts a string and a byte array
Function method3(ByVal parameter1 As String, ByVal parameter2 As Byte()) As String
2. Added a section to the web.config so larger messages could be sent
<bindings>
<basicHttpsBinding>
<binding maxReceivedMessageSize="2100000000"></binding>
</basicHttpsBinding>
</bindings>
WCF Service Configuration
<system.serviceModel>
<bindings>
<!--This needs to be changed to http if debugging and https for production-->
<!--<basicHttpBinding>
<binding maxReceivedMessageSize="2100000000"></binding>
</basicHttpBinding>-->
<basicHttpsBinding>
<binding maxReceivedMessageSize="2100000000"></binding>
</basicHttpsBinding>
</bindings>
<services>
<service name="penergydata.penergydata">
<host>
<baseAddresses>
<!--This needs to be changed to http if debugging and https for production-->
<!--<add baseAddress="http://localhost:49427/"/>-->
<add baseAddress="https://wcfservices.myefaactweb.com/penergydata/"></add>
</baseAddresses>
</host>
<!--This needs to be changed to http if debugging and https for production-->
<!--<endpoint address="" binding="basicHttpBinding" contract="penergydata.Ipenergydata"/>-->
<endpoint address="" binding="basicHttpsBinding" contract="penergydata.Ipenergydata"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<!--This needs to be changed to http if debugging and https for production-->
<!--<add binding="basicHttpBinding" scheme="http"/>-->
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
Client Configuration
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_Ipenergydata">
<security mode="Transport"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://wcfservices.myefaactweb.com/penergydata/penergydata.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_Ipenergydata" contract="penergydata.Ipenergydata" name="BasicHttpsBinding_Ipenergydata"/>
</client>
</system.serviceModel>
Make sure you change your binding type in your client. The client and service bindings have to match. You can always use svcutil to get the correct config info for a service as well.
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="BasicHttpsBinding_Ipenergydata">
<security mode="Transport"/>
</binding>
</basicHttpsBinding>
</bindings>
<client>
<endpoint address="https://wcfservices.myefaactweb.com/penergydata/penergydata.svc" binding="basicHttpsBinding" bindingConfiguration="BasicHttpsBinding_Ipenergydata" contract="penergydata.Ipenergydata" name="BasicHttpsBinding_Ipenergydata"/>
</client>
</system.serviceModel>
I ran my WCF service on the server without SSL enabled and now I moved it to one with SSL enabled and I am getting the following error:
Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https].
Below are my settings:
<bindings>
<basicHttpBinding>
<binding name="basicHTTP">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows">
</transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="basicBehavior" name="ProjectName.MyService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHTTP" contract="ProjectName.IMyService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="basicBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
How can I fix this error?
You need to define a binding for basicHttps. This is a very simple settings that works for SSL:
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="BasicHttpBinding_IMyService" />
</basicHttpsBinding>
</bindings>
<client>
<endpoint
name="BasicHttpBinding_IMyService"
address="https://MyURL/MyService.svc/soap/"
binding="basicHttpsBinding"
bindingConfiguration="BasicHttpBinding_IMyService"
contract="ClientServiceReference.IMyService" />
</client>
</system.serviceModel>
Note: The endpoint needs to be defined and its URL is https.
Also, make sure that in production environment, you are not sending the exception details back to the caller (that would be considered a security hole in your system because exceptions can reveal too much information to hackers). You must change this line:
<serviceDebug includeExceptionDetailInFaults="false"/>
Fixed the issue by specifying security mode as Transport and using webHttpBinding
I have added a binding to the config below:
<services>
<service name="MyNamespace.Service.ServiceName.ServiceEndPoint">
<endpoint address="http://localhost:8012/ServiceEndPoint" binding="webHttpBinding" contract="MyNamespace.Service.ServiceName.IServiceEndPoint" behaviorConfiguration="webHttp" name="ServiceName"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
So I've added the binding="webHttpBinding" as I'd like to secure the end point. Here's the corresponding config I have:
<bindings>
<wsHttpBinding>
<binding name="ServiceName">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
but this appears to not be securing the end point. I've tried this with Firefox to confirm IE isn't automatically authenticating and checked the headers in firebug.
Can anyone point me in the direction of the right config for doing this?
Thanks,
Matt
you forget to set bindingConfiguration
<endpoint address="http://localhost:8012/ServiceEndPoint" binding="webHttpBinding" contract="MyNamespace.Service.ServiceName.IServiceEndPoint" behaviorConfiguration="webHttp" name="ServiceNameEndpoint" bindingConfiguration="ServiceName"/>
In your binding you have configured a wsHttpBinding and in your service endpoint you have specified a webHttpBinding. I think you want your endpoint binding to be set to wsHttpBinding.
Check this link on WCF Bindings.
I have successfully configured 3 endpoints for my prototype service. The endpoints are basicHttpBinding, wsHttpBinding, and webHttpBinding. The only glitch I have at the moment is in the WCFTestClient. When I point it to my service it lists the first two, but not the webHttpBinding. I can test the REST endpoint through my browser and it works just fine. Here's my config:
<system.serviceModel>
<services>
<service behaviorConfiguration="serviceBehaviour" name="VMDServices.VMDService">
<endpoint binding="webHttpBinding"
address="rest" behaviorConfiguration="webBehaviour" contract="VMDServices.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint binding="basicHttpBinding"
address="basic" bindingConfiguration="basicBinding" contract="VMDServices.IService1">
</endpoint>
<endpoint binding="wsHttpBinding"
address="ws" bindingConfiguration="wsBinding" contract="VMDServices.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None"></security>
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsBinding" transactionFlow="true">
<security mode="None"></security>
<reliableSession enabled="true" ordered="true" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<!-- 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>
Is there any reason why I can't see the webHttpEndpoint in the WCFTestClient tool?
Cheers,
Dany.
It's because web endpoints (unlike SOAP ones) do not expose metadata, so the test client doesn't know about it when it downloads the WSDL for the service. Unlike SOAP, which has well-defined formats for exposing metadata (WSDL, MEX), web (a.k.a. REST) endpoints do not.
That's the short story. If you want to know more details, I wrote a blog post about it at http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx
The following is a list of features not supported by WCF Test Client:
• Types: Stream, Message, XmlElement, XmlAttribute, XmlNode, types that implement the
IXmlSerializableinterface, including the related XmlSchemaProviderAttribute attribute, and the XDocument and XElement types and the ADO.NET DataTable type.
• Duplex contract.
• Transaction.
• Security: CardSpace , Certificate, and Username/Password.
• Bindings: WSFederationbinding, any Context bindings and Https binding, WebHttpbinding (Json response message support).
Source: http://msdn.microsoft.com/en-us/library/bb552364.aspx
try adding the "mexHttpBinding" endpoint that exposes the metadata
I have defined maxBufferSize = 2147483647, maxBufferPoolSize = 2147483647, maxReceivedMessageSize = 2147483647 in the server config file but when i generate client config file, values for all these parameters are defaulted in there and i have to edit them manually. This is how i generate the client config file
svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config net.tcp:/
/localhost:4365/MyService
Also since i am using maximum values in the maxBufferSize, maxBufferPoolSize, maxReceivedMessageSize and maxItemsInObjectGraph, is that going to hit the performance?
--Server config values--
<bindings>
<netTcpBinding>
<binding name="MySvc_InsecureTcp" closeTimeout="00:01:10" openTimeout="00:01:10" receiveTimeout="24.20:31:23.6470000"
listenBacklog="1000" maxConnections="1000" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport protectionLevel="None" />
</security>
</binding>
<binding name="MySvc_mexBinding" closeTimeout="00:01:10" openTimeout="00:01:10" receiveTimeout="24.20:31:23.6470000"
listenBacklog="1000" maxConnections="1000" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport protectionLevel="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyService">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentCalls="30" maxConcurrentInstances="2147483647" maxConcurrentSessions="30" />
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyNameSpace.MyService" behaviorConfiguration="MyService">
<endpoint address="" binding="netTcpBinding" contract="MyNameSpace.IMyService"
bindingConfiguration="MySvc_InsecureTcp" name="netTcpMySvc" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="netTcpBinding" contract="IMetadataExchange"
bindingConfiguration="MySvc_mexBinding" name="mexMySvc" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:4365/MyService"/>
</baseAddresses>
</host>
</service>
</services>
--After doing some more testing--
maxItemsInObjectGraph doesnt get included in the client config file. And if client is sending large objects, maxItemsInObjectGraph should be changed manually.
<behaviors>
<endpointBehaviors>
<behavior name="FASTServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
Not every configuration value defined on the service is passed to the client through metadata. Buffer sizes and reader quotas are one example because each participant in the communication can setup its own values - those values are defense against Denial of Service attack and can differ between service and client based on exchanged messages. For example if you want only upload large data sets you must set them correctly on the service but you don't need to modify them on the client. Downloading has reverse effect.
This is normal. Those properties are limited to that configuration file and don't carry across the service. Clients and servers can have different size limits, largely to help protect the sever against outrageously long requests (that the client might be expecting).