views:

1041

answers:

3

I have a WCF service implemented with a call back contract that I am trying to send a business object through. I have the business object decorated with DataContract() and DataMember() attributes, and it contains the following number of properties:

  • ints: 3
  • strings: 4
  • XElement: 1
  • other objects: 5 (also decorated with DataContract() and DataMember()

Whenever I try and send this object over the callback, the service times-out. I have tried creating other objects with fewer properties to send through the callback, and can get it to go through if there is only one property, but if I have any more than one property, the service times out.

Is there something wrong in my configuration? I have tried the default wsDualHttpBinding, as well as a customBinding (as displayed below) and I have tried all sorts of different settings with the maxBufferSize, maxBufferPoolSize, and maxReceivedMessageSize. I don't want to increase the timeout, as I would like this object to arrive to my client fairly quickly. Please somebody help me...if I had any hair left I would have pulled it out by now!!!!!

I have configured my service as such:

Server Configuration:

    <customBinding>
        <binding name="DualBindingConfig">
            <reliableSession flowControlEnabled="true" maxPendingChannels="128" />
            <compositeDuplex />
            <oneWay/>
            <binaryMessageEncoding/>
            <httpTransport maxReceivedMessageSize="655360000" maxBufferPoolSize="655360000" />
        </binding>
    </customBinding>
    <services>
        <service behaviorConfiguration="Agent_Utility_WCF.Callback.AgentMessagingBehavior"
            name="Agent_Utility_WCF.Callback.AgentMessaging">
            <endpoint address="" binding="customBinding" bindingConfiguration="DualBindingConfig" bindingName="AgentMessaging" contract="Agent_Utility_WCF.Callback.IAgentMessaging">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="Agent_Utility_WCF.Callback.AgentMessagingBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceThrottling maxConcurrentCalls="160" maxConcurrentSessions="100"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>

Client Configuration:

<bindings>
    <customBinding>
        <binding name="AgentMessaging_IAgentMessaging">
            <reliableSession acknowledgementInterval="00:00:00.2000000" flowControlEnabled="true"
                inactivityTimeout="00:10:00" maxPendingChannels="4" maxRetryCount="8"
                maxTransferWindowSize="8" ordered="true" reliableMessagingVersion="Default" />
            <compositeDuplex />
            <oneWay maxAcceptedChannels="10" packetRoutable="false">
                <channelPoolSettings idleTimeout="00:02:00" leaseTimeout="00:10:00"
                    maxOutboundChannelsPerEndpoint="10" />
            </oneWay>
            <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                maxSessionSize="2048">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            </binaryMessageEncoding>
            <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                useDefaultWebProxy="true" />
        </binding>
    </customBinding>
</bindings>
<client>
    <endpoint address="http://localhost:666/Callback/AgentMessaging.svc"
        binding="customBinding" bindingConfiguration="AgentMessaging_IAgentMessaging"
        contract="AgentMessaging.IAgentMessaging" name="AgentMessaging_IAgentMessaging">
        <identity>
            <dns value="localhost" />
        </identity>
    </endpoint>
</client>
A: 

Add the following to your web.config:

<system.diagnostics>
    <trace autoflush="true">
        <listeners>
        </listeners>
    </trace>
    <sources>
        <source name="System.ServiceModel"
                switchValue="Information, ActivityTracing"
                propagateActivity="true">
            <listeners>
                <add name="sdt"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData= "WcfDetailTrace.svclog" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>

Then invoke your web service method. This will generate WcfDetailTrace.svclog in the root of your web site. Open this file with SvcTraceViewer.exe. This should give you pretty much information on what's going on.

Darin Dimitrov
Doing this yielded these results:There was an error while trying to serialize parameter http://tempuri.org/:submittedJob. The InnerException message was 'Type 'Utility.DAO.SubmittedJob' with data contract name 'SubmittedJob:http://schemas.datacontract.org/2004/07/Utility.DAO' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.
sunmorgus
You could use the KnownTypeAttribute (http://whiletrue.nl/blog/?p=36) in order to list all classes deriving from your base class.
Darin Dimitrov
I think I found the issue...in the webservice I had defined the method as accepting an object type, and was trying to send in a type of SubmittedJob. I changed the webservice to accept SubmittedJob, and the timeout error went away.
sunmorgus
A: 

How big are the other objects? For example, how large is the XElement's subtree? The graph for an object can get quite large eventually, in particular if it calls into other objects.

A simple investigative approach might be to remove the [DataMember] attributes except perhaps one of the strings, and re-introduce them one at a time until it breaks.

Marc Gravell
I created another test object with only one property with this goal in mind and successfully submitted it through my webservice. I added another property after that and it would no longer go through...
sunmorgus
the XElement is actually pretty small...
sunmorgus
A: 

I would take a look at http://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/.

mattruma
Thanks for the answer, but I have abandoned the silverlight project for now.
sunmorgus
I almost had to abandon one as well, until I found this ... maybe next time!
mattruma