WCF, CSLA, and Callbacks/duplex communication

WCF, CSLA, and Callbacks/duplex communication

Old forum URL: forums.lhotka.net/forums/t/2559.aspx


Curelom posted on Tuesday, March 20, 2007

I'm excited Rockford is incorporating wcf into csla.  As I am still cutting my teeth on wcf, I was wondering what would be the best route to go for my situation.

I have an application that uses csla business objects and Sql Server 2005 SqlDependency.  Within the Fetch operation I create a dependency link on the command and attach it to an event within the business object.  This allows me to receive any changes from the sql server based on the query.

wcf seems like it would be a good solution for this using a channel with it's duplex communication such as WSDualHttpBinding.  My question is what would be the best way to implement this with CSLA?  Will the CSLA native channel allow for this?  Should I create an separate class to wcf into the server and grab the callbacks from a repository of some sort?  or would it be better to build a custom csla channel?  Or is there another option?

RockfordLhotka replied on Tuesday, March 20, 2007

You can certainly grab the current 3.0 code from svn and experiment.

This is not an area on which I've been focusing, and the data portal itself doesn't need or use any sort of callback mechanism.

However, the data portal doesn't do anything that should block you from passing a client-side object reference to the server. You could do that through the Remoting channel too, though obviously configuring Remoting to handle the callback was harder than it should be with WCF.

The data portal requires that your criteria and business objects be serializable (Serializable or DataContract) so they can move across the wire. However, I would expect that your client-side business object could reference a non-serializable MBRO (or the WCF equivalent, whatever that might be). That reference should flow to the server as a proxy, enabling a callback.

That, at least, is what happened in Remoting. Again, I haven't tried to establish any callback scheme in WCF through the data portal, so I don't know for sure.

Curelom replied on Tuesday, March 20, 2007

I'm trying to grab from svn://svn.lhotka.net/csla  I get an error "Can't connect to host 'svn.lhotka.net': No connection could be made because the target machine actively refused it."

 

RockfordLhotka replied on Tuesday, March 20, 2007

That's odd. Can you ping svn.lhotka.net? And are you sure your local firewall allows outbound connections on whatever port svn uses (I don't remember it offhand, but it is like 3390 or something)?

Curelom replied on Wednesday, March 21, 2007

It's probably my work's firewall.  I'll have to try it when I get home.

Curelom replied on Wednesday, March 28, 2007

I've been working on getting the wcf channel working.  No duplex stuff yet, just getting the basics.  My client is able to fetch data just fine, however when I do a save, I get the below error.  When I configure the client to use web services, it works fine.  Have you come across anything like this?  I've tried both the NetDataContractSerializer and the binary serializer with the same effect.

An exception of type 'System.ServiceModel.ProtocolException' occurred and was caught.

-------------------------------------------------------------------------------------

03/28/2007 11:22:41

Type : System.ServiceModel.ProtocolException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : The remote server returned an unexpected response: (400) Bad Request.

Source : mscorlib

Help link :

Data : System.Collections.ListDictionaryInternal

TargetSite : Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)

Stack Trace :

Server stack trace:

   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)

   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)

   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)

   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)

   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)

   at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)

   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

 

Exception rethrown at [0]:

   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

   at Csla.Server.Hosts.IWcfPortal.Update(UpdateRequest request)

   at Csla.DataPortalClient.WcfProxy.Update(Object obj, DataPortalContext context) in F:\My Downloads\microsoft\cslacs-3.0.0-070325\cslacs\Csla\DataPortal\Client\WcfProxy.cs:line 95

   at Csla.DataPortal.Update(Object obj) in F:\My Downloads\microsoft\cslacs-3.0.0-070325\cslacs\Csla\DataPortal\Client\DataPortal.cs:line 316

   at Csla.DataPortal.Update[T](T obj) in F:\My Downloads\microsoft\cslacs-3.0.0-070325\cslacs\Csla\DataPortal\Client\DataPortal.cs:line 269

   at Csla.BusinessListBase`2.Save() in F:\My Downloads\microsoft\cslacs-3.0.0-070325\cslacs\Csla\BusinessListBase.cs:line 642

   at MyCompany.Helpdesk.Library.TicketList.Save() in C:\VS2005\Projects\HelpDesk App\Library\TicketList.cs:line 191

   at HelpDesk.HelpdeskMainForm.hELPDESKBindingNavigatorSaveItem_Click(Object sender, EventArgs e) in C:\VS2005\Projects\HelpDesk App\HelpDesk\HelpDeskMain.cs:line 194

 

Additional Info:

 

Curelom replied on Wednesday, March 28, 2007

Please disregard the last message.  I was able to figure it out, being a configuration error.

FireGarden replied on Monday, September 17, 2007

I am having a similar error. Can you tell me how you fixed your problem? What was your config error?

Curelom replied on Monday, September 17, 2007

I abandoned wcf a while ago and I'm using web services.  I plan on revisiting it in the future, but I was getting too many problems for it's value.

If I remember right I as having a few issues, one was the size of my businesslist would often be bigger then the default maxReceivedMessageSize.  I was also having some difficulties with security on the callback, so I removed security as I had no secure data coming through the callback.

The config I had on the server side was this

<bindings>

<wsDualHttpBinding>

<binding name="WSDualHttpBinding_WcfTicketService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="01:00:00" sendTimeout="00:01:00" bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">

<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>

<reliableSession ordered="false" inactivityTimeout="01:00:00"/>

<security mode="None">

<message establishSecurityContext="false"/>

</security>

</binding>

</wsDualHttpBinding>

<wsHttpBinding>

<binding name="WSHttpBinding_IWcfPortal" closeTimeout="00:02:00" openTimeout="00:01:00" receiveTimeout="00:2:00" sendTimeout="00:02:00" bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="1655360" messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="true">

<readerQuotas maxDepth="32" maxStringContentLength="655360" maxArrayLength="15655360" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>

</binding>

</wsHttpBinding>

</bindings>

 

The client side was this

<bindings>

<wsDualHttpBinding>

<!--clientBaseAddress="http://localhost:808/WcfTicketService/"-->

<binding name="WSDualHttpBinding_WcfTicketService" receiveTimeout="1:00:00">

<security mode="None"/>

</binding>

</wsDualHttpBinding>

<wsHttpBinding>

<binding name="WSHttpBinding_IWcfPortal" closeTimeout="00:02:00"

openTimeout="00:01:00" receiveTimeout="00:2:00" sendTimeout="00:02:00"

bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard"

maxBufferPoolSize="524288" maxReceivedMessageSize="15655360"

messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"

allowCookies="true">

<readerQuotas maxDepth="32" maxStringContentLength="655360" maxArrayLength="15655360"

maxBytesPerRead="4096" maxNameTableCharCount="16384" />

</binding>

</wsHttpBinding>

</bindings>

besto replied on Monday, July 28, 2008

Hi

Did you ever solve your problem? I'm facing the exact same error. Same conditions, same error message and same stack trace.

Curelom replied on Monday, July 28, 2008

Sorry, I haven't revisted this issue yet.  Probably won't for some time.

Copyright (c) Marimer LLC