WCF (Indigo) & NetTcpBinding

Posts   
 
    
Shara
User
Posts: 19
Joined: 18-Jul-2005
# Posted on: 28-Feb-2006 00:52:49   

Has anyone been using this?

For a project I'm working on I'm trying to pass Adapter entities and collections from a Self-Hosted service to my client application (both the service and the client are running on the same machine at the moment, for development).

Originally I had my service setup as an WsHttpBinding service hosted in II6. While this worked for sending an Entity it didn't work for a Collection, and I figured it had something to do with the way the collections get serialized (XML). I really didn't want to take the time to go from an LLBLGenPro collection to a DataSet and back - seems like a waste of time to me when Frans/Otis has done such a nice job with Adapter already to provide me with the entities I need.

So I switched gears and decided to go with the NetTcpBinding, figuring it would serialize in Binary and I'd get my Collection. Unfortunately it's not working...

I can pass a simple type from my service to my client so I know the service connection itself works. But I have no idea what's up. Maybe my configuration isn't serializing as binary?

Just curious if we have anyone using Indigo right now who has also run into this issue.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 28-Feb-2006 08:41:57   

I haven't tried it myself and I'm not that familiar with WCF at the moment that I can say "it's not working because of ... " or "it should work... ". MS plans to release WinFX later this year, I estimate Q3. We'll add support for WCF and the other parts when they're released.

Frans Bouma | Lead developer LLBLGen Pro
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 28-Feb-2006 12:53:46   

Indigo is on my short list, so when I find out more I will post here.

Shara
User
Posts: 19
Joined: 18-Jul-2005
# Posted on: 28-Feb-2006 17:40:42   

Otis wrote:

I haven't tried it myself and I'm not that familiar with WCF at the moment that I can say "it's not working because of ... " or "it should work... ". MS plans to release WinFX later this year, I estimate Q3. We'll add support for WCF and the other parts when they're released.

I am guessing the problem lies in the way WCF handles DataContracts with complex types and that is why they won't work. If that's the case it's a bummer for the short term.

In light of this, I suppose the best method now is to provide the LLBLGen objects via a Remoting service. Then hopefully it shouldn't be too hard to simply switch to a WCF service once WinFX is released and LLBL is updated.

Shara
User
Posts: 19
Joined: 18-Jul-2005
# Posted on: 28-Feb-2006 19:00:03   

Update:

Well, the initial bug was a moron-move. I'd forgot to include the DB connection string in the config file. Doh!

But now I"m back to the same problem I had with the Http WebService - I can retrieve an EmployeeEntity just fine, but retrieving an EntityCollection isn't happening.

I have a console server app and I am doing a WriteLine on the server-side to ensure that the EntityCollection has some number of items in it. But when it gets over to the Client side the EntityCollection is empty.

EDIT:

According to this link:

http://msdn.microsoft.com/msdnmag/issues/06/02/WindowsCommunicationFoundation/default.aspx

Objects marked with the [Serializable] attribute should work with WCF. It reads:

WCF also supports serializing types marked with [Serializable], which allows .NET remoting types to work with WCF without change. WCF provides an implicit mapping for [Serializable] types where all public/private fields are automatically serialized.

Both the Entities and EntityCollection are marked as [Serializable]. The Entities take it a step further and implement ISerializable, but the Collection does not (for obvious reasons).

I am puzzled why my EntityCollection is empty on the client side...

Shara
User
Posts: 19
Joined: 18-Jul-2005
# Posted on: 01-Mar-2006 17:59:02   

Additional update on this problem:

I posted this to the Indigo boards on MSDN and they suggested I trace the message to see how the object is being handled over the wire. Notice the left and right brackets inside the message <Body> get transformed to < and > (I chopped a good portion of the message body to keep it from messing up this board format)


<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
  <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
    <EventID>0</EventID>
    <Type>3</Type>
    <SubType Name="Information">0</SubType>
    <Level>8</Level>
    <TimeCreated SystemTime="2006-03-01T16:33:17.6563193Z" />
    <Source Name="System.ServiceModel.MessageLogging" />
    <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
    <Execution ProcessName="EVE" ProcessID="3784" ThreadID="1" />
    <Channel/>
    <Computer>CHRISH</Computer>
  </System>
  <ApplicationData>
    <TraceData>
      <DataItem>
        <MessageLogTraceRecord Time="2006-03-01T08:33:17.6563193-08:00" Source="ServiceLevelReplyIn" Type="System.ServiceModel.Channels.PatternMessage" xmlns="http://schemas.microsoft.com/ServiceModel/2004/06/Management/MessageTrace">
          <s:Envelope xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
            <s:Header>
              <a:Action s:mustUnderstand="1">http://tempuri.org/IEmployeeDataService/SearchByEmployeeNameResponse</a:Action>
              <a:RelatesTo>urn:uuid:baf65c9c-9e2f-4c20-9291-5e52437ca3d4</a:RelatesTo>
              <a:To s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:To>
            </s:Header>
           <s:Body>
              <SearchByEmployeeNameResponse xmlns="http://tempuri.org/">
                <SearchByEmployeeNameResult>&lt;EntityCollection&gt;&lt;Entities&gt;&lt;EmployeeEntity EmployeeId="44"&gt;&lt;EntityCollectionReference ............</SearchByEmployeeNameResult>
              </SearchByEmployeeNameResponse>
            </s:Body>
          </s:Envelope>
        </MessageLogTraceRecord>
      </DataItem>
    </TraceData>
  </ApplicationData>
</E2ETraceEvent>

I was wondering why an EntityCollection would have that happen. I could have swore I read something about this on this forum, but I can't find it now.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 02-Mar-2006 11:28:48   

Shara wrote:

Update: But now I"m back to the same problem I had with the Http WebService - I can retrieve an EmployeeEntity just fine, but retrieving an EntityCollection isn't happening.

Please, let's get one thing straight: Binary/SoapFormatter based serialization != Xml Serialization! It's a completely different way of converting live objects to data and back. Webservices use Xml serialization.

[Serializable], ISerializable are part of the *Formatter framework and therefore aren't used by Xml serialization.

I have a console server app and I am doing a WriteLine on the server-side to ensure that the EntityCollection has some number of items in it. But when it gets over to the Client side the EntityCollection is empty.

EDIT:

According to this link:

http://msdn.microsoft.com/msdnmag/issues/06/02/WindowsCommunicationFoundation/default.aspx

Objects marked with the [Serializable] attribute should work with WCF. It reads:

WCF also supports serializing types marked with [Serializable], which allows .NET remoting types to work with WCF without change. WCF provides an implicit mapping for [Serializable] types where all public/private fields are automatically serialized.

Both the Entities and EntityCollection are marked as [Serializable]. The Entities take it a step further and implement ISerializable, but the Collection does not (for obvious reasons).

I am puzzled why my EntityCollection is empty on the client side...

EntityCollection does implement ISerializable, as its base class does. The base class also implements IXmlSerializable, so that should work as well.

About the < > conversion mistery: it seems that the XML produced by the EntityCollection xml serialization code is embedded as string by WCF... very weird.

Frans Bouma | Lead developer LLBLGen Pro
Shara
User
Posts: 19
Joined: 18-Jul-2005
# Posted on: 02-Mar-2006 16:41:16   

Otis wrote:

[Serializable], ISerializable are part of the *Formatter framework and therefore aren't used by Xml serialization.

I think you misunderstand. I am using a WCF net.Tcp transport. It should use a binary format over TCP. That's why I was puzzled that it wasn't working, though the EntityCollection was marked as [Serializable] (and as you say, the base class implements ISerializable). I was only commenting that the problem was similiar in nature to what I experienced previously when trying to implement the service as an http web service - namely that in both cases I was having a problem with the EntityCollection travelling over the wire.

I switched from a WebService to the net.Tcp binding after reading from the MSDN site that objects marked as Serializable or implementing ISerializable should be fine with WCF. I didn't want to use Remoting since Indigo is at a suitable state (and something I'll want to use when it is released), so I opted for the net.Tcp.

Otis wrote:

EntityCollection does implement ISerializable, as its base class does. The base class also implements IXmlSerializable, so that should work as well.

About the < > conversion mistery: it seems that the XML produced by the EntityCollection xml serialization code is embedded as string by WCF... very weird.

One of the Microsoft guys on MSDN thought that it was a problem with the way the EntityCollectionw a deserializing. So I downloaded the latest veresion of LLBLGenPro (mine was about a year old).

**This solved the problem simple_smile **

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 02-Mar-2006 17:19:55   

Aha! simple_smile Glad it's now working and thanks for testing/going through the hassle to get this working! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Shara
User
Posts: 19
Joined: 18-Jul-2005
# Posted on: 02-Mar-2006 17:37:25   

Otis wrote:

Aha! simple_smile Glad it's now working and thanks for testing/going through the hassle to get this working! simple_smile

Aye!

What's cool is - now I know if you want to use LLBLGenPro with WCF, as long as you use a net.Tcp Binding, you don't have to change anything. It works right out of the box.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 02-Mar-2006 18:46:14   

That is really good news, Shara! simple_smile . I really wouldn't overhaul the complete serialization pipeline again... wink

Frans Bouma | Lead developer LLBLGen Pro
Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 05-Jun-2006 18:37:24   

Shara, I'd love some guidance on how you set the whole thing up. Let me know!

Jeff M
User
Posts: 250
Joined: 04-Aug-2004
# Posted on: 06-Jun-2006 00:45:54   

Shara wrote:

Aye!

What's cool is - now I know if you want to use LLBLGenPro with WCF, as long as you use a net.Tcp Binding, you don't have to change anything. It works right out of the box.

Man, that is good news! Great work, Shara.