Chris Marisic
Chris Marisic

Reputation: 33128

WSDL handling practices for external service

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?

Upvotes: 0

Views: 460

Answers (2)

dovholuk
dovholuk

Reputation: 969

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..

Upvotes: 1

Daniel Brückner
Daniel Brückner

Reputation: 59705

Doesn't the following work as expected?

svcutil *.wsdl *.xsd /language:C#

Upvotes: 0

Related Questions