Web service, REST interface, WSDL, ASMX, C#

Markus Freitag 3,791 Reputation points
2022-01-13T14:38:39.43+00:00

I think it is important to mention that you tagged this post as ASP.NET Core and this question is ASP.NET not Core. Secondly, ASMX is a very old technology. If you need a JSON response then create a Web API project.

I need to connect to a customer who has a WebService. From this customer I get a WSDL file. Not an executable server. The idea is to write a mock server.

What is the current technology? What would I have to request from the customer? Which file? How can I easily include this in my client C# desktop application.

Thanks for tips. Thanks for a server and a client sample

Windows for business Windows Server User experience Other
Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2022-01-13T15:32:42.37+00:00

    The WSDL (Web Service Definition Language) is an XML file that documents request and response types as well as the remote method signatures. Read the WSDL and write the method stubs. If you are looking for a code generator to produce method stubs from a WSDL, then do a Google search and find a utility that best fits your needs. Adding a service reference or using the wsdl.exe or svcutil.exe will generate the request/response types. Just copy the types to the mock service project.

    create stubs from wsdl c#

    What is the current technology?

    WSDLs document SOAP (XML) services.

    What would I have to request from the customer? Which file?

    Again the WSDL file. Service owners generally expose a testing site. Contact the the service owner for support as they know their systems and can guide you far better than a ASP.NET support forum.

    How can I easily include this in my client C# desktop application.

    It is a matter of learn the fundamentals. If the service owner has a test site then create a service reference as explained in your other thread using Visual Studio. If the service owner only provides an out-of-band WSDL which is atypical then use the wsdl.exe or svcutil.exe to generate the C# source. Both utilities let you select an output location. Read the documentation!

    Creating the Web Service Proxy
    ServiceModel Metadata Utility Tool (Svcutil.exe)

    Adding code to an ASP.NET Visual Studio project is very easy. Just copy the files using Windows Explorer to a folder in your project or if you used the code generators make sure the output is a folder in your project.. If you cannot see the files in solution explorer, then right click and highlight Add -> Existing item... Find the file(s) and click ok.

    For ASP.NET Core projects just add the files to a folder in the project.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Limitless Technology 39,916 Reputation points
    2022-01-14T20:42:16.917+00:00

    Hi @Markus Freitag

    You can use some tools like Postman to achieve this. You can make requests that return mock data defined within Postman if you do not have a production API ready, or you do not want to run your requests against real data yet. By adding a mock server to your collection and adding examples to your requests, you can simulate the behavior of a real API.

    Hope this resolves your Query!!

    ------
    --If the reply is helpful, please Upvote and Accept it as an answer--

    1 person found this answer helpful.

  2. P a u l 10,761 Reputation points
    2022-01-13T14:59:24.51+00:00

    If you have the .wsdl file then you'll just need to add the Service Reference to your solution described here:
    https://learn.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide

    This will generate a C# service reference that you can instantiate, configure & proxy your requests through. You'll just need the service address (which will be a URI ending in .svc) to configure your reference.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.