Ahuman
Ahuman

Reputation: 762

How to combine multiple WSDL proxies into one class in .net core?

I have a few WSDL files sharing the same set of classes/types behind with different service contracts. I would like to reuse the types across the service contract proxies. All the examples I find online are related to .net framework, not for .net core.

This documentation helps me to create a proxy for a single WSDL. Not for multiple. https://learn.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide

Upvotes: 1

Views: 2542

Answers (2)

This is based upon @Ahuman answer. But more detailed.

Step 1: Create single wsdl files for each service from existing WCF services. For example if your Web service address is http://localhost:50286/EcomService.svc you can create your wsdl file form the http://localhost:50286/EcomService.svc?singleWsdl

Step2: Create a connected service reference using standard way by selecting one of the generated wsdl file. This will create a ConnectedService.json file under "Connected Services" -> "Your namespace name"

Step3: Edit the ConnectedService.json file and include additional wsdl files under "inputs".

  "ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
  "Version": "15.0.40203.910",
  "ExtendedData": {
    "inputs": [
      "../../wsdl/EcomService.wsdl",
      "../../wsdl/ProfileService.wsdl"
    ], ...

Disadvantage: Whenever there is a change in the WCF services, you have to manually generate the wsdl files at your ASP.NET Core project, before updating the Connected Service.

Upvotes: 1

Ahuman
Ahuman

Reputation: 762

Here is the solution that worked for me. Follow the steps mentioned in this article https://learn.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide.

This will generate ConnectedService.json file. Edit that file to include multiple WSDL files like below.

"ExtendedData": {
    "inputs": [
      "C:/Users/Bogus/Downloads/Bogus1.wsdl",
      "C:/Users/Bogus/Downloads/Bogus2.wsdl"
    ],
    "collectionTypes": [
      "System.Array",
      "System.Collections.Generic.Dictionary`2"
    ],
    "namespaceMappings": [
      "*, Bogus.Namespace"
    ],

Once modified, update the service reference by right-clicking the target connected service.

Upvotes: 1

Related Questions