drunkenRabbit
drunkenRabbit

Reputation: 394

Adding Service Reference for WCF Service generates empty reference.cs

I have seen this question before (here for one), however the solution is to not reuse referenced assemblies. I need to reuse included assemblies because multiple services reference the same shared Objects. If I do not reuse the assemblies I get namespace errors because the same Object is referenced through different namespaces. (ie. Service1.Object, Service2.Object)

In short, I need the generated Client class that extends the ClientBase for the web service but I cannot untick the reuse referenced assemblies as I need shared Objects with the same namespace. Any suggestions?

Upvotes: 1

Views: 3996

Answers (2)

Sean B
Sean B

Reputation: 11607

You can generate your client proxy with svcutil.exe and use the /r switch to specify assemblies that you want referenced instead of re-emitted in the auto-generated client proxy code.

  • ProjACommon
  • ProjBSvc
    • References ProjACommon
  • ProjCClient
    • References ProjACommon
    • You want a client that references ProjA types and/or code rather than them being auto-generated into a new namespace within C

After building ProjBSvc exec the following, which outputs .wsdl & .xsd

svcutil.exe ProjBSvc.dll

2nd consume the wsdl & xsd to generate a proxy/client:

svcutil.exe *.wsdl *.xsd /o:<ProjCClientPath>/Client.cs /r:ProjACommon.dll

ProjCClient references Client.cs generated from previous steps

Build and examine with the object browser and you will see the types in C referencing the types in A instead of new types with the same name in C's namespace. You may want /tcv and /n as well as other switches to meet your needs.

Here is an article that may help. It also links to the Microsoft documentation for svcutil

Upvotes: 1

Jeff
Jeff

Reputation: 982

Use a mapper, meaning you will have to duplicate the models(objects) and have a class the maps the objects from one namespace to the next.

Upvotes: 0

Related Questions