About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).
Showing posts with label wcf. Show all posts
Showing posts with label wcf. Show all posts

Friday, October 14, 2011

WCF & Silverlight max buffer size issue

Ran into these problems a few times with the WCF errors, in which the buffer size was the issue:
  • “The remote server returned an error: NotFound”
  • "Unable to read data from the transport connection: The connection was closed"
  • "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."
This would be an easy solution if only dealing with the WCF. Since, we are using the WCF layer to pass data to/from the Silverlight layer the problem arises in two locations -- not one.

Over at Mehroz's Experiments (http://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/) he goes into good detail on solving this problem.

So in the Silverlight's ServiceReferences.ClientConfig we increase the buffer size.

Code Snippet
 <binding name="BasicHttpBinding_IScientificDataService"   closeTimeout="00:01:00"openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered">
    <security mode="None"/>
binding>



In the WCF's Web.config, we needed to increase the maxBufferSize and maxReceivedMessageSize to a larger number



Code Snippet
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        behavior>
      serviceBehaviors>
    behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
  system.serviceModel>

Wednesday, March 12, 2008

WCF Binding Info

BasicHttpBinding

Element Collection

System.ServiceModel.Channels.TextMessageEncodingBindingElement
System.ServiceModel.Channels.HttpTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • WS-*Interoperability

Use if

  • Need basic level of interoperability

Performance : Good

Communication

  • Request/Reply
  • One-Way


WSHttpBinding

Element Collection

System.ServiceModel.Channels.TransactionFlowBindingElement
System.ServiceModel.Channels.SymmetricSecurityBindingElement
System.ServiceModel.Channels.TextMessageEncodingBindingElement
System.ServiceModel.Channels.HttpTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • WS-*Interoperability
  • WS-*Transactions
  • Reliable Sessions / Reliable Messaging

Use if

  • Need WS-* level of interoperability

  • Don't need duplexing

  • Don't need federated security

Performance : Good

Communication

  • Request/Reply
  • One-Way


WSDualHttpBinding

Element Collection

System.ServiceModel.Channels.TransactionFlowBindingElement
System.ServiceModel.Channels.ReliableSessionBindingElement
System.ServiceModel.Channels.SymmetricSecurityBindingElement
System.ServiceModel.Channels.CompositeDuplexBindingElement
System.ServiceModel.Channels.OneWayBindingElement
System.ServiceModel.Channels.TextMessageEncodingBindingElement
System.ServiceModel.Channels.HttpTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • WS-*Interoperability
  • WS-*Transactions
  • Reliable Sessions / Reliable Messaging

Use if

  • Need WS-* level of interoperability

  • Need Duplexing

Performance : Good

Communication

  • Request/Reply
  • One-Way
  • Duplex


NetTcpBinding

Element Collection

System.ServiceModel.Channels.TransactionFlowBindingElement
System.ServiceModel.Channels.BinaryMessageEncodingBindingElement
System.ServiceModel.Channels.WindowsStreamSecurityBindingElement
System.ServiceModel.Channels.TcpTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • WS-*Transactions
  • Reliable Sessions / Reliable Messaging

Use if

  • Don't need interoperability

  • Is not local

  • Don't need queuing

  • Don't need peer networking

Performance : Better

Communication

  • Request/Reply
  • One-Way
  • Duplex


NetNamedPipeBinding

Element Collection

System.ServiceModel.Channels.TransactionFlowBindingElement
System.ServiceModel.Channels.BinaryMessageEncodingBindingElement
System.ServiceModel.Channels.WindowsStreamSecurityBindingElement
System.ServiceModel.Channels.NamedPipeTransportBindingElement

Support Features

  • Transport-Level Security
  • WS-*Transactions

Use if

  • Don't need interoperability

  • Is local

Performance : Best

Communication

  • Request/Reply
  • One-Way
  • Duplex


NetMsmqBinding

Element Collection

System.ServiceModel.Channels.BinaryMessageEncodingBindingElement
System.ServiceModel.Channels.MsmqTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • Durable Reliable Messaging

Use if

  • Don't need interoperability

  • Is not local

  • Need Queuing

  • Don't need legacy MSMQ

Performance : Better

Communication

  • One-Way


NetPeerTcpBinding

Element Collection

System.ServiceModel.Channels.PnrpPeerResolverBindingElement
System.ServiceModel.Channels.BinaryMessageEncodingBindingElement
System.ServiceModel.Channels.PeerTransportBindingElement

Support Features

  • Transport-Level Security

Use if

  • Don't need interoperability

  • Is not local

  • Need queuing

  • Need peer networking

Performance : Good

Communication

  • One-Way
  • Duplex


MsmqIntegrationBinding

Element Collection

System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement

Support Features

  • Transport-Level Security
  • Durable Reliable Messaging

Use if

  • Don't need interoperability

  • Is not local

  • Need queuing

  • Need legacy MSMQ

Performance : Better

Communication

  • One-Way


WSFederationHttpBinding

Element Collection

System.ServiceModel.Channels.TransactionFlowBindingElement
System.ServiceModel.Channels.SymmetricSecurityBindingElement
System.ServiceModel.Channels.TextMessageEncodingBindingElement
System.ServiceModel.Channels.HttpTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • WS-*Interoperability
  • Reliable Sessions / Reliable Messaging

Use if

  • Need WS-* level of Interoperability

  • Don't need duplexing

  • Need federated security

Performance : Good

Communication

  • Request/Reply
  • One-Way

WS2007HttpBinding

Element Collection

System.ServiceModel.Channels.TransactionFlowBindingElement
System.ServiceModel.Channels.SymmetricSecurityBindingElement
System.ServiceModel.Channels.TextMessageEncodingBindingElement
System.ServiceModel.Channels.HttpTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • WS-*Interoperability
  • WS-*Transactions
  • Reliable Sessions / Reliable Messaging

Use if

  • Need WS-* level of Interoperability

  • Don't need duplexing

    Don't need federated security

Performance : Good

Communication

  • Request/Reply
  • One-Way


WS2007FederationHttpBinding

Element Collection

System.ServiceModel.Channels.TransactionFlowBindingElement
System.ServiceModel.Channels.SymmetricSecurityBindingElement
System.ServiceModel.Channels.TextMessageEncodingBindingElement
System.ServiceModel.Channels.HttpTransportBindingElement

Support Features

  • Transport-Level Security
  • Message-Level Security
  • WS-*Interoperability
  • Reliable Sessions / Reliable Messaging

Use if

  • Need WS-* level of Interoperability

  • Don't need duplexing

  • Need federated security

Performance : Good

Communication

  • Request/Reply
  • One-Way

Tuesday, March 04, 2008

WCF Error: HTTP could not register URL http://+:80/Temporary_Listen_Addresses// because TCP port 80 is being used by another application

So I was doing a dual http binding (WSDualHttpBinding) [page 53-54 in Essential Windows Communication Foundation For .Net Framework 3.5] when I got the error above. I doubled checked by running the svcutil and the wizard, but with no luck.

 

Found the solution at(http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2782499&SiteID=1)

 

Just need to include the clientBaseAddress attribute with a URI in the binding tag, since the default is using port 80.

 

<?xml version="1.0" encoding="utf-8"?>

<configuration>

   <system.serviceModel>

      <bindings>

         <wsDualHttpBinding>

               <binding   name="WSDualHttpBinding_IServerStock"

                        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"

                        clientBaseAddress="http://localhost:8001/WCFDuplexService">

               <readerQuotas   maxDepth="32"

                           maxStringContentLength="8192"

                           maxArrayLength="16384"

                           maxBytesPerRead="4096"

                           maxNameTableCharCount="16384" />

               <reliableSession   ordered="true"

                              inactivityTimeout="00:10:00" />

               <security   mode="Message">

                  <message   clientCredentialType="Windows"

                           negotiateServiceCredential="true"

                           algorithmSuite="Default" />

               </security>

            </binding>

         </wsDualHttpBinding>

      </bindings>

      <client>

         <endpoint   address="http://localhost:8000/WCFDuplexService"

                  binding="wsDualHttpBinding"

                  bindingConfiguration="WSDualHttpBinding_IServerStock"

                  contract="IServerStock"

                  name="WSDualHttpBinding_IServerStock">

            <identity>

               <userPrincipalName value="wandrus@mbsnav.com" />

            </identity>

         </endpoint>

      </client>

   </system.serviceModel>

</configuration>

Generating WCF's app.config and proxy class.

Currently reading: Essential Windows Communication Foundation for .Net Framework 3.5. The book is written for Visual Studio 2008, but I'm running on VS 2005 -- which means that I will have to run the svcutil.exe instead of using the wizard on some cases.  A quick reminder on how to do so:

 

Synchronous:

svcutil <Host Service IMetadataExchange address> -config:app.config -out:generatedProxy.cs

Example:

svcutil http://localhost:8000/EssentialWCF/mex -config:app.config -out:generatedProxy.cs

Asynchronous:

Example:

svcutil http://localhost:8000/EssentialWCF/mex -config:app.config -out:generatedProxy.cs /async

The svcutil.exe comes with Microsoft's SDK 6.0, for more information on this tool can be found at: http://msdn2.microsoft.com/en-us/library/aa347733.aspx

Friday, November 02, 2007

WCF Tutorial

My first attempt at using WCF, thanks to http://msdn2.microsoft.com/en-us/vbasic/bb736015.aspx was very successful.

I did change the language to C# for my version, since I perfer it over VB.Net. There were some changes that I had to go about in a different way to get it to be successful.

Example:

Dim t As Type = GetType(ServiceLib.HelloService)

vs.

ServiceLib.HelloService hs = new ServiceLib.HelloService();


Type t = Type.GetTypeArray(new object[]{hs})[0];

Thursday, September 27, 2007

Biztalk Apps

Here are some BizTalk apps that can be used to make development easier.

BizTalk SSO Configuration Data Storage Tool (http://seroter.wordpress.com/2007/09/21/biztalk-sso-configuration-data-storage-tool/) - A Single Sign-On App that sets access permissions for applications, account groups, etc..

CodePlex's BizTalk Open Source Apps (http://www.codeplex.com/Project/ProjectDirectory.aspx?TagName=BizTalk) - Dissambler, MicroSoft ESB Guidance, automated testing, distributed systems, biztalk server 2006 documenter, pipeline component wizard, tcpip adapter, wcf adapter, biztalk server 2006 orchestration profiler, biztalk extensions, pattern wizard, adapter wizard, lifecycle management, solution kits, app software factory, map tester, host configurator for applications, powershell, counters, etc........