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>
Related
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.
I am using Custom binding in my WCF services and Proxies. I am creating proxies by inheriting from DuplexClientbase. Is there a option in WCF which helps me to get the username, who invoked the method?
Here is my binding
<bindings>
<customBinding>
<binding name="CustomPipeBinding" maxConnections="10" openTimeout="01:20:00" receiveTimeout="20.00:00:00" sendTimeout="01:20:00" closeTimeout="01:20:00">
<windowsStreamSecurity protectionLevel="None" />
<namedPipeTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
<binding name="CustomTcpBinding" maxConnections="10" openTimeout="01:20:00" receiveTimeout="20.00:00:00" sendTimeout="00:05:00" closeTimeout="01:20:00">
<windowsStreamSecurity protectionLevel="None" />
<reliableSession />
<tcpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
You need to configure your service to require impersonation as outlined in this MSDN article. Since you are defining a custom binding, you'll need to add the required security element config to allow WCF to pass the Windows credentials from the client to the service.
In your service code, you'll need to access the ServiceSecurityContext.Current.WindowsIdentity static property to get what you need.
I have the below given setting in my web.config of my WCF service, this was working fine till today and suddenly started giving the error "An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail." I have verified the time in my server and client it's same.
Any thoughts?
<bindings>
<customBinding>
<binding name="stsBinding">
<security authenticationMode="UserNameOverTransport" requireDerivedKeys="false"
keyEntropyMode="ServerEntropy" requireSecurityContextCancellation="false"
requireSignatureConfirmation="false">
</security>
<httpsTransport maxReceivedMessageSize="66665536"/>
</binding>
</customBinding>
<wsFederationHttpBinding>
<binding name="serviceFederation">
<readerQuotas maxStringContentLength="2147483647"
maxDepth="2147483647"
maxBytesPerRead="2147483647"
maxArrayLength="2147483647"/>
<security mode="TransportWithMessageCredential">
<!-- Ping token type MUST be SAML 1.1, do not change -->
<message issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
negotiateServiceCredential="false">
<!-- TODO: You must put the proper issuer URN of the Ping STS; normally this would be the Ping base URL -->
<issuer address="https://my-sso-server.com"
binding="customBinding" bindingConfiguration="stsBinding" />
</message>
</security>
</binding>
Things to check:
Is there any windows patch that has been installed, sometimes this tightens security and stops things working.
Is there a password that has expired, often the cause when things stop working.
I have been tasked to look after an ASP.Net WebForms application that communicates with a WCF service hosted by a Windows service. The binding used for the service is netTcpBinding.
The service exposes methods to Upload and Download ‘files’. The user select to upload a file and the HttpPostFile.InputSteam is passed directly to the service as a parameter in the service 'Upload' method. The service saves the stream as a byte array to the database [database field data type is varbinary (max)].
The file download data flow is essentially the reverse process. The bytes are retrieved from the database; loaded into a MemoryStream in the WCF service; and then returned to the Web Application.
I have captured the data contained in the streams (sent / received) at each step in the above operations - on the client (web app) and the service. I have looped through and written out to a flat file the bytes contained in each stream.
The byte array in each case is identical [byte value; and number of bytes in the stream] except for the File Download operation. At the point where the stream is returned to the Web Application from the WCF service. Here the number of bytes received is correct but only the first 255 bytes are populated. The values of the remaining bytes are zero
I have made a host of experimental changes to the binding values - in both the client at service - as I believe that the problem must lie here. To date I have not influenced the status of the bytes returned in any way. The logs for the Client and service do not show any that any exceptions are thrown or any other problems.
I do not have much experience in setting the correct combinations of binding (and other configuration) attributes for Client and Server applications – having relied on defaults in the past. We need the service and client to be configured to transfer the maximum allowable file size. Unfortunately I cannot use MTOM.
This post and links, did not offer me any insight. So far I have found no other information that helps.
Hopefully someone can assist me with what the issue might be. Below are the bindings that I am using:
Client [web.config]:
<bindings>
<netTcpBinding>
<binding name="TCP"
closeTimeout="00:01:00"
openTimeout="00:10:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00"
transferMode="Streamed"
maxBufferPoolSize="512"
maxBufferSize="2147483647"
maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
Service:
<netTcpBinding>
<binding name="netTCP"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00"
transferMode="Streamed"
listenBacklog="30"
maxBufferPoolSize="512"
maxBufferSize="2147483647"
maxConnections="30"
maxReceivedMessageSize="2147483647"
portSharingEnabled="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
Silly me. I think I have got it.
The bindings were OK. I was not dealing with reading the bytes correctly from the stream into the buffer on the client.
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?