none
CustomBinding instead of basicHttpBinding?

    Question

  • I have added a number of Silverlight Enabled WCF web services to my Silverlight web project.

    Recently I discovered that calls that I make to these services are blocking the UI as well as any subsequent calls, which does not make sense to me because I thought asynchronous web service calls are supposed to execute in parallel, not sequentially, but they are executing sequentially.

    After much searching, I found many posts stating that to solve this issue is simple: simply enable the ClientHTTPStack instead of the BrowserHttpStack. This is pretty easy especially considering if you start your project from the business application template you get these lines of code already in your app.xaml.vb file:

     

            HttpWebRequest.RegisterPrefix("http://", Net.Browser.WebRequestCreator.ClientHttp)
            HttpWebRequest.RegisterPrefix("https://", Net.Browser.WebRequestCreator.ClientHttp)
    

    So I tried simply uncommenting these lines of code, but no luck, a call to a specific web service function is still blocking the UI and subsequent service calls until the first one completes.

    So I start digging further and I come across something. All of the WCF services I have added to the project seem to have been configured as "Custom" bindings, and I don't know if this is correct. I have seen a lot of example web.config files that show WCF bindings defined as basicHTTPBindings.

    Here is what my bindings look like in web.config:

        <bindings>
    
          <basicHttpBinding>
            <binding name="ReportServiceBinding" maxReceivedMessageSize="50000000"
              transferMode="Streamed" />
          </basicHttpBinding>
    
          <customBinding>
    
            <binding name="WebTS3.Web.wcfEmail.customBinding0">
              <binaryMessageEncoding />
              <httpTransport />
            </binding>
    
            <binding name="WebTS3.Web.svcCustomDictionary.customBinding0">
              <binaryMessageEncoding />
              <httpTransport />
            </binding>
    
            <binding name="WebTS3.Web.svcReports.customBinding0">
              <binaryMessageEncoding />
              <httpTransport />
            </binding>
    
            <binding name="WebTS3.Web.svcUser.customBinding0">
              <binaryMessageEncoding />
              <httpTransport />
            </binding>
    
            <binding name="WebTS3.Web.svcOffice.customBinding0">
              <binaryMessageEncoding />
              <httpTransport />
            </binding>
    
          </customBinding>
    
          <webHttpBinding>
            <binding name="ReportServiceRestBinding" transferMode="Streamed" />
          </webHttpBinding>
    
          <pollingDuplex>
            <binding name="myPollingDuplex" duplexMode="MultipleMessagesPerPoll" />
          </pollingDuplex>
    
        </bindings>

     and:

        <services>
    
          <service name="WebTS3.Web.wcfEmail">
            <endpoint address="" binding="customBinding" bindingConfiguration="WebTS3.Web.wcfEmail.customBinding0"
              contract="WebTS3.Web.wcfEmail" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
    
          <service name="WebTS3.Web.svcCustomDictionary">
            <endpoint address="" binding="customBinding" bindingConfiguration="WebTS3.Web.svcCustomDictionary.customBinding0"
              contract="WebTS3.Web.svcCustomDictionary" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
    
          <service behaviorConfiguration="ReportServiceBehavior" name="DevExpress.XtraReports.Service.ReportService">
            <endpoint binding="basicHttpBinding" bindingConfiguration="ReportServiceBinding"
              contract="DevExpress.XtraReports.Service.IReportService" />
            <endpoint address="rest" behaviorConfiguration="ReportServiceRestBehavior"
              binding="webHttpBinding" bindingConfiguration="ReportServiceRestBinding"
              contract="DevExpress.Xpf.Printing.Service.IExportServiceRest" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
    
          <service name="WebTS3.Web.ChatService">
            <endpoint address="" binding="pollingDuplex" bindingConfiguration="myPollingDuplex"
              contract="WebTS3.Web.ChatService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
    
          <service name="WebTS3.Web.svcReports">
            <endpoint address="" binding="customBinding" bindingConfiguration="WebTS3.Web.svcReports.customBinding0"
              contract="WebTS3.Web.svcReports" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
    
          <service name="WebTS3.Web.svcUser">
            <endpoint address="" binding="customBinding" bindingConfiguration="WebTS3.Web.svcUser.customBinding0"
              contract="WebTS3.Web.svcUser" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
    
          <service name="WebTS3.Web.svcOffice">
            <endpoint address="" binding="customBinding" bindingConfiguration="WebTS3.Web.svcOffice.customBinding0"
              contract="WebTS3.Web.svcOffice" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
    
        </services>

    And in my ServiceReferences.ClientConfig:

    <configuration>
        <system.serviceModel>
            <bindings>
                <customBinding>
                    <binding name="CustomBinding_wcfEmail">
                        <binaryMessageEncoding />
                        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                    </binding>
                    <binding name="CustomBinding_svcCustomDictionary">
                        <binaryMessageEncoding />
                        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                    </binding>
                    <binding name="CustomBinding_svcUser">
                        <binaryMessageEncoding />
                        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                    </binding>
                    <binding name="CustomBinding_svcReports" >
                        <binaryMessageEncoding />
                        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"  />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <endpoint address="../Services/Email/wcfEmail.svc" binding="customBinding"
                    bindingConfiguration="CustomBinding_wcfEmail" contract="EmailService.wcfEmail"
                    name="CustomBinding_wcfEmail" />
                <endpoint address="../Services/UserDictionary/svcCustomDictionary.svc"
                    binding="customBinding" bindingConfiguration="CustomBinding_svcCustomDictionary"
                    contract="UserDictionary.svcCustomDictionary" name="CustomBinding_svcCustomDictionary" />
                <endpoint address="../Services/User/svcUser.svc" binding="customBinding"
                    bindingConfiguration="CustomBinding_svcUser" contract="UsernameService.svcUser"
                    name="CustomBinding_svcUser" />
                <endpoint address="../Services/Reports/svcReports.svc"
                    binding="customBinding" bindingConfiguration="CustomBinding_svcReports"
                    contract="ReportingService.svcReports" name="CustomBinding_svcReports"/>
            </client>
        </system.serviceModel>
    </configuration>

    Does anyone see any issues with this? Any reason why my wcf services calls are blocking the UI and it does not seem to matter whether or not I enable the clientHTTPstack?

    Thanks,

    Josh

     

     

    Friday, January 20, 2012 2:52 PM

Answers