I have a WCF service that is returning a lot of data. I want to compress that information so I thought that using BinaryEncoding would be appropriate.
Currently, I have a binding setup in my web.config as follows:
<binding name="myCustomBinding" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:05:00" sendTimeout="00:05:00">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="8388608" maxBufferSize="8388608">
<extendedProtectionPolicy policyEnforcement="Never" />
</httpTransport>
</binding>
In my ServiceReferences.clientconfig file, I have the following binding settings:
<binding name="CustomBinding_MyService">
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<extendedProtectionPolicy policyEnforcement="Never" />
</httpTransport>
</binding>
Oddly, this configuration will not work. As soon as I remove the <binaryMessageEncoding /> line from the web.config, everything works fine.
My question is, how do I use binary message encoding? Is there something I need to configure in my ServiceReferences.clientconfig?
Thank you
Can you define "will not work"?
Note that the client and server must agree; Silverlight has only a limited subset of extension points, but it seems that <binaryMessageEncoding/> is supported (source and more info) - so perhaps add it to the client?
Related
I need to authenticate an endpoint using certificate in WCF Config file
I have tried adding with the various authenticationMode setting
but its not working in customBinding
could you please help me to convert the below code to the custom binding
<basicHttpBinding>
<binding name="certBinding">
<security mode="Message">
<message clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
This is the code i have tried in custom binding
<customBinding>
<binding name="OutbBinding1" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="20000000" maxArrayLength="20000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<security authenticationMode="SecureConversation">
<secureConversationBootstrap authenticationMode="AnonymousForCertificate" />
</security>
</binding>
</customBinding>
As we know, if we use the message security of BasicHttpbinding, we should set up the certificate both in the client and the server. In addition, we should also establish a certificate trust relationship between the server and the client.
One more thing needs to note is, different from the authentication mode of the transport layer security, we need to set a default service certificate (non-client certificate, use the trusted server certificates for signing messages) on the client side.
So anyway, the below configuration could achieve the same goal that authenticates the client with a certificate. please refer to the below configuration.
<customBinding>
<binding name="TehRealBinding">
<textMessageEncoding />
<security authenticationMode="MutualCertificate" />
<httpTransport />
</binding>
</customBinding>
Besides, the following document might be useful to you.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/securitybindingelement-authentication-modes
Feel free to let me know if there is anything I can help you.
I have WCF service hosted on IIS 7.5 communicating via HTTP protocol. It is confugured as customBinding, see below. It requires session and it has no protection level yet.
<customBinding>
<binding name="customHttpBinding" openTimeout="00:15:00" sendTimeout="00:15:00" receiveTimeout="00:15:00" closeTimeout="00:15:00">
<reliableSession ordered="false" />
<security requireSignatureConfirmation="false" enableUnsecuredResponse="true" />
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
<httpTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
Client is MS Excel AddIn that on user's purpose call asynchronously 6 different operation contracts. Everything works and looking good until I open Fiddler. There I see multiple identical HTTP requests:
I browsed the content of these identical responses and it really holds identical data. In debug mode I made myself sure that the client calls every operation contract one time only and the service method runs one time only as well.
The question is how to reduce multiple requests?
In the past I have that configured as wsHttpBinding and the data was not requested multiple times but we need a little more control over configuration as it will be deployed on multiple servers.
I don't want to transfer the same data multiple times on the network, in other cases I need to transfer larger data (about hundreds of MB).
UPDATE
According to spodger question, here is client configuration:
<customBinding>
<binding name="customHttpBinding" openTimeout="00:15:00" sendTimeout="00:15:00" receiveTimeout="00:15:00" closeTimeout="00:15:00">
<reliableSession ordered="false" acknowledgementInterval="00:00:30" inactivityTimeout="00:15:00" flowControlEnabled="true" />
<security requireSignatureConfirmation="false" enableUnsecuredResponse="true" />
<textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />
<httpTransport maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" requestInitializationTimeout="00:10:00" />
</binding>
</customBinding>
I would just like to enable gzip compression to the following binding.
Here is what I have in my config file currently.
<netHttpsBinding>
<binding name="MutualCertificateBinding" maxReceivedMessageSize="9223372036854775807" receiveTimeout="00:20:00" sendTimeout="00:20:00" transferMode="Streamed" messageEncoding="Binary">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
<webSocketSettings transportUsage="Always" />
</binding>
</netHttpsBinding>
According to MSDN tcp, http, and https in WCF are all capable of compression as of 4.5, I'm on 4.5.2.
Keep in mind I'm actually using a WCF contract with a callback contract so duplex is required.
I'm happy to replace my binding with a custom binding as I control both sides and they are both .net but I've been unable to figure out how to create any custom binding that supports websockets.
Any help would be appreciated, thanks.
Okay I kept trying tons of different things and here is what I finally came up with and it's working. :)
<binding name="GZipMutualCertificateBinding" receiveTimeout="00:20:00" sendTimeout="00:20:00">
<binaryMessageEncoding compressionFormat="GZip" />
<httpsTransport maxReceivedMessageSize="9223372036854775807" requireClientCertificate="true" transferMode="Streamed">
<webSocketSettings transportUsage="Always" />
</httpsTransport>
</binding>
This was found by trial and error, please let me know if you see anything that looks out of place. Thanks.
When I upload a photo from my WP7 to my WCF web service I get '413 Request Entity Too Large', and no matter what I do, I cannot stop it from happening.
My binding information for the web service is:
<bindings>
<basicHttpBinding>
<binding name="uploadfilebinding" closeTimeout="10:01:00"
maxBufferSize="2147483646" maxBufferPoolSize="2147483646"
maxReceivedMessageSize="2147483646" openTimeout="10:01:00"
receiveTimeout="10:10:00" sendTimeout="10:01:00"
messageEncoding="Mtom" transferMode="StreamedRequest">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646"
maxArrayLength="2147483646" maxBytesPerRead="2147483646"
maxNameTableCharCount="2147483646" />
</binding>
</basicHttpBinding>
</bindings>
As you can see I have set maxReceivedMessageSize to the highest I can, but to no avail, Can anyone help me please?
My server is 'Windows Server 2008 R2 Standard' and the service is running under .NET 4.
Thanks in advance,
Lee
P.S. If you need anymore information, please ask and I'll post it.
Thanks for the replies:
As this is a WP7 app, the client configuration file is a hidden file called 'ServiceReferences.ClientConfig' that is created by the service, and the binding in there is now:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMbcSync" closeTimeout="10:01:00"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" openTimeout="10:01:00"
receiveTimeout="10:10:00" sendTimeout="10:01:00"
transferMode="StreamedResponse">
</binding>
</basicHttpBinding>
</bindings>
But I'm still getting the same error. Any more suggestions would be much appreciated?
Lee
There are multiple places that you may increase to the maximum possible size. Some of them are WCF related and some of them are IIS related. In addition to the options mentioned in the comments, try to increase the followings (maxRequestLength, and maxAllowedContentLength) in your config file on the server side to take care of the IIS side too:
<system.web>
<httpRuntime maxRequestLength="2147483647" useFullyQualifiedRedirectUrl="true" executionTimeout="14400"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxAllowedContentLength="2147483647"/>
<fileExtensions allowUnlisted="true"/>
<verbs allowUnlisted="true"/>
</requestFiltering>
</security>
</system.webServer>
I am trying to create a WCF service that needs to be consumed by a Java client. Requirements from the Java client is to disable WS-Addressing. I must have to use WSHttpBinding. First of all I am bit new to this. I did some quick search online but was not able to figure out if that is the correct solution. Can somebody please point me to right direction ?
Thanks
Use http://webservices20.cloudapp.net/ for such issues. You did not specify which security you need. One option is
<!-- generated via Yaron Naveh's http://webservices20.blogspot.com/ -->
<customBinding>
<binding name="NewBinding0">
<transactionFlow />
<security authenticationMode="UserNameOverTransport" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
</customBinding>
<!-- generated via Yaron Naveh's http://webservices20.blogspot.com/ -->