views:

76

answers:

1

I have a Silverlight 4 user control that calls a WCF service residing within an ASP.NET 4 web application.

Anonymous access to the webservice is enabled. clientaccesspolicy.xml is in place and downloads successfully. Navigating to FieldITDbService.svc on the server correctly pulls up the service metadata.

However, when I try to view the test page for the Silverlight control that calls this WCF service, the service itself returns:

HTTP/1.1 200 OK
Date: Thu, 22 Jul 2010 21:15:54 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Content-Encoding: gzip
Content-Length: 4409
Cache-Control: private
Content-Type: application/soap+msbin1

and then times out without returning data. I am baffled. Does anyone know why this would happen or how I can more effectively debug it? I am trace logging the service but there are no errors in the log -- according to the log, it's working.

Here's a link showing what happens (from Fiddler2): http://imgur.com/VwgqS.png

Here is the code in MainPage.xaml.cs that calls the webservice:

var webService = new FieldITDbServiceClient();
webService.ReadVAMDataCompleted += webService_ReadVAMDataCompleted;
webService.ReadVAMDataAsync();
webService.CloseAsync();

Here is the ClientConfig in the Silverlight project used to call the webservice:

<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="CustomBinding_FieldITDbService">
                <binaryMessageEncoding />
                <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://[ipofmyserverhere]/FieldIT/FieldITDBService.svc"
            binding="customBinding" bindingConfiguration="CustomBinding_FieldITDbService"
            contract="DbServiceRef.FieldITDbService" name="CustomBinding_FieldITDbService" />
    </client>
</system.serviceModel>

Here is the code in the actual WCF service, FieldITDbService.svc:

 [ServiceContract( Namespace = "" )]
    [AspNetCompatibilityRequirements( RequirementsMode = AspNetCompatibilityRequirementsMode.Required )]
    public class FieldITDbService
    {
        [OperationContract]
        public List<VAM> ReadVAMData()
        {
            List<VAM> allData = new List<VAM>();
            using( FieldITEntities dbContext = new FieldITEntities() )
            {
                allData.AddRange( dbContext.VAMs.ToList() );
            }
            return allData;
        }
    }

Here is the serviceModel section in the web apps web.config file:

 <system.serviceModel>
    <diagnostics>
      <messageLogging maxMessagesToLog="100"
          logEntireMessage="true"
          logMessagesAtServiceLevel="true"
          logMalformedMessages="true"
          logMessagesAtTransportLevel="true">
      </messageLogging>
    </diagnostics>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="FieldIT.FieldITDbService.customBinding0">
          <binaryMessageEncoding />
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <services>
      <service name="FieldIT.FieldITDbService">
        <endpoint address="" binding="customBinding" bindingConfiguration="FieldIT.FieldITDbService.customBinding0"
          contract="FieldIT.FieldITDbService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
A: 

Switching to client HTTP handling by putting the line

 WebRequest.RegisterPrefix( "http://", WebRequestCreator.ClientHttp );

in the MainPage() constructor fixed this problem instantly and for all browsers. I have no idea why or how, but I'm just going to accept it and move on at this point.

http://msdn.microsoft.com/en-us/library/dd920295%28v=VS.95%29.aspx

Daniel Coffman
Was it timing out in all other browsers?
Scott Robinson
It worked briefly in IE (and I think Chrome but I only tested it once and don't really remember) but never in Firefox. For the last three days it has been timing out in all three.
Daniel Coffman