S h o r t S t o r i e s

// Tales from software development

Creating a mock web service with Visual Studio

leave a comment »

It’s possible to create the basis of a mock web service quickly using Microsoft’s WSDL tool and Visual Studio.

I usually have to remind myself of the required WSDL parameters required to create the service interface as the default is to generate client proxy classes rather than the service interface.

This is a good guide: https://ivangrigoryev.com/en/how-to-mock-a-web-service-in-dot-net/

The key point is to specify the ServerInterface option of the WSDL tool so that it generates a source file for the interface that a mock web service needs to implement. The example given in the article referenced above is:

wsdl /language:CS /out:C:\Downloads\ /protocol:SOAP /serverinterface C:\Downloads\webservice.wsdl

Then add the interface source file generated to a blank Visual Studio Web Service project, add a new class and open the source file, and specify that it implements the interface by adding

: interface-name

after the class name. Finally, right-click on the interface name you added and select Implement Interface so that Visual Studio creates method stubs for all the web service’s methods.

Written by Sea Monkey

November 13, 2020 at 10:28 am

Posted in Development

Tagged with ,

Leave a comment