views:

146

answers:

2

I have a project where it's dependent on Oracle Hosted web services (not WCF). I have a copy of the WSDLs for the services and their correlated XSDs.

What is the proper way of generating the proxies and datacontract assembly for this?

I started with

XSD.exe /c /language:CS user.xsd

For each of my xsds. This generate a bunch of class objects with shared type violations (same object in all of the classes) so I pruned all the duplicates so they had single declarations.

Then built that assembly with only my classes files "datacontracts.dll"

Then I generated my service clients

svcutil.exe user.wsdl /n*:SomeNameSpace /r:datacontracts.dll /noconfig

But this didn't really seem to give what i want since it still caused all of the duplication of the classes inside the service clients.

Inside the classes generated from the XSDs I did notice each class definition had

[XmlType(Namespace = "urn:/crmondemand/xml/...")]

Do I need to place that attribute the way it shows up on repeated classes once for each class inside where I have made it be the singular class? So that I would have

[XmlType(Namespace = "urn:/crmondemand/xml/user")]
[XmlType(Namespace = "urn:/crmondemand/xml/campaign")]
[XmlType(Namespace = "urn:/crmondemand/xml/lead")]
public class SharedClass

Or am I approaching this wrong?

A: 

Doesn't the following work as expected?

svcutil *.wsdl *.xsd /language:C#
Daniel Brückner
I'm not sure if this worked as expected, I got a whole bunch of different classes for same names like Account1 Account2 etc. It's probably their XSD's messed up =/
Chris Marisic
+1  A: 

First a warning... you probably know - but in case you don't I'd certainly say that pruning generated code is a recipe for disaster...

As for reusing types - I myself have never found the Microsoft stack to be particularly good in this regard... there are two lines of thought though... One says that "all web services" - by their very nature - are separate entities... As such - all code that is emitted is only valid inside that one web service.

I find this to be incredibly short sighted. I much prefer to reuse any types I can... However with .NET I found this to be very hard... The closest thing I've found was a tool called WSCF. It does some nice things that I really like such as emitting separate cs files for each class. This makes "overwriting" them from some other source- as long as the source generates serializble equivalents - quite easy...

The problem I had with WSCF (classic mind you) is that it doesn't do "xml namespace" to "c# namespace" mapping... I actually had to add that to the tool myself... (I tried to commit it back to the project but never heard back sadly)

So I would tell you to try out WSCF.blue (targets WCF) or look into WCF classic. You can find them both on codeplex.

Hope that helps you out..

dovholuk
"dependent on Oracle Hosted web services (not WCF)" if i had control over the code that i could replace the web service with WCF I'd probably just be using NHibernate anyway.
Chris Marisic
I'll go for this answer since it really just acknowledges web services that are not WCF suck and the problem is the web service isn't WCF.
Chris Marisic
well thanks Chris - but I'm actually advocating that Every Microsoft stack for web services I've used "sucks" in this regard (for the most part though - I like MS's stack)... I really encourage you look into WSCF.Blue... I think it can do what you're looking for - or at least get you a lot closer... (I use it on every project I deal with in .NET) Where you'll find the biggest 'bang' for your buck is the option to 'emit in separate files'... Then - even if the EXACT same class is emitted more than once it just gets overwritten ... (assuming they aren't 'actual' name clashes)
dovholuk