Oid causing problems to WCF WSDL generator behavior?

172 views
Skip to first unread message

Gabriel Duford

unread,
Oct 15, 2010, 10:25:52 AM10/15/10
to mongodb-csharp
Hi,
We have WCF services that we host in IIS 7.5. One way we use to test
that the service is up and running is by using a browser and point it
to the .svc file. That used to show a web page that starts with:
"You have created a service.

To test this service, you will need to create a client and use it to
call the service. You can do this using the svcutil.exe tool from the
command line with the following syntax: [...]"

However, when a service gets or returns objects which have an Oid
somewhere in the object tree, we get an error page that starts with:
The service encountered an error.

An ExceptionDetail, likely created by
IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to
a WSDL export extension:
System.ServiceModel.Description.DataContractSerializerOperationBehavior
contract: http://tempuri.org/:IMyService ---->
System.MissingMethodException: No parameterless constructor defined
for this object.

Because of this (I think), it is not possible to use wcftestclient to
test the service, the "add service reference" in VS returns errors,
etc. Calling the service when the service and data contracts are
shared between the client and the service is no problems. The Oid
serializes just fine. It is just the WSDL extension that has problem
with it. I isolated the problem by elimination. When I got my service
down to data not having Oids, it worked just fine.

Anyone ever had this problem? Is there a workaround? The reason why it
causes me problems is that it gets pretty hard to debug a WCF issue
when you can't eliminate variables by using simple tools that requires
the metadata of the service.

Thanks,

gabriel

craiggwilson

unread,
Oct 15, 2010, 7:48:09 PM10/15/10
to mongodb-csharp
Hi Gabriel,
I personally don't use Oid for anything unless it is internal.
Instead, I use Guids, which work just fine with Wcf.

If you want to continue to use Oids, then perhaps you should create an
Oid wrapper and use that in your objects. I'd suggest using Guids
though.

Gabriel Duford

unread,
Oct 15, 2010, 11:28:36 PM10/15/10
to mongodb-csharp
Thanks Craigg.
Since I exchange (POCO) objects that are stored in Mongo through my
WCF services, and because Oid is the native unique identifier in
Mongo, I thought it would be better to try to make it work. Guid or
Oid is not important, as long as the entity is uniquely identified.
I think I'll just change all my POCO IDs to Guid instead of Oid, which
will fix my WCF services.

I'm curious what in the Oid class makes the WSDL behavior extension
break, however...

gabriel

Ed

unread,
Oct 25, 2010, 9:01:38 PM10/25/10
to mongodb-csharp
Also, OID is a Mongo specific concept. By passing that down to your
service layer and to clients you are leaking implementation details.
Ideally that would all be abstracted away. To enforce true separation
the client should never need to know anything about the
implementation.

Gabriel Duford

unread,
Oct 25, 2010, 11:41:07 PM10/25/10
to mongodb-csharp
True, but the class requires an ID, no matter what the type is. Having
to implement a wrapper or copy-class or message interceptors or ?? to
hide away these details is way more maintenance, so we exchange the
POCO classes.
Now that I have been told there's no issue with using a Guid type as
the _id of an entity, I will simply use this instead.

gabriel
Reply all
Reply to author
Forward
0 new messages