Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One entity shared across two web services?

I'm working on a project where I have 2 web services that need the same entity. The 2 web services are on the same server so on the back-end, they share the same classes.

On the front-end side, my code consumes both web services and sees the entities from both services as separate (in different namespaces) so I can't use the entity across both services.

Does anyone know of a way to allow this to work in .NET 2.0?

I've done this with my entity:

[XmlType(TypeName = "Class1", Namespace = "myNamespace")]
public class Class1
{
    public int field;
}

Hoping that my IDE would somehow "know" that the class is the same on both web services so that it wouldn't create separate entities for both classes, but no luck.

Is this possible to do with .NET 2.0 web services?

like image 370
Dan Herbert Avatar asked Sep 02 '26 03:09

Dan Herbert


1 Answers

I think that you can not do that from inside VS but you can manually use the wsdl.exe utility like this:

wsdl.exe /sharetypes http://localhost/MyService1.asmx?wsdl http://localhost/MyService2.asmx?wsdl

Notice the /sharetypes option which turns on the type sharing feature. This feature creates one code file with a single type definition for identical types shared between different services (the namespace, name, and wire signature must be identical).

More info:

  • Web Services Description Language tool
  • Framework 2.0 - WebServices Shared Types
like image 199
Panos Avatar answered Sep 04 '26 18:09

Panos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!