Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reuse existing classes from another Service Reference

The situation that I'm working with is suboptimal, so bear with me..

We are to consume external (non .NET) SOAP-webservices.
For some reason, each method is implemented in a separate web service with it's own WSDL.
A lot of the objects returned by the web services have the exact same design, name and xml namespace.

"Add Service Reference" is used because:
- the internal dev team are used to it
- we'd like to keep the automatic "Update Service Reference"

The 2nd reference is added with the "Reuse types in all referenced assemblies" option on.
All of the classes are however generated again under the new reference.

Is where a way to reuse the classes from the 1st reference?

like image 614
David Avatar asked Feb 19 '13 13:02

David


1 Answers

You can add multiple WSDLs if you open your Service Reference's Reference.svcmap (to find it, check "Show All Files" and expand your service reference) and edit it manually, rather than setting the WSDL URI through the GUI. E.g.

  <MetadataSources>
    <MetadataSource Address="http://localhost/example1.wsdl" Protocol="http" SourceId="1" />
    <MetadataSource Address="http://localhost/example2.wsdl" Protocol="http" SourceId="2" />
  </MetadataSources>

When you have multiple WSDLs in one Service Reference, classes will be reused as you describe, as long as they're identical in the different WSDLs. If there are classes with the same name but different definitions, one of them will have a '1' suffix appended to its name.

like image 57
Tim S. Avatar answered Oct 07 '22 21:10

Tim S.