Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF How to generate service from wsdl and xsd - Contract First

Tags:

c#

wsdl

wcf

xsd

I need to generate a web service based on wsdl and xsd defined by external party. This is for Healthcare and wsdl and xsd is defined by an external committee and it has to be implemented as defined (www.caqh.org/SOAP/WSDL/CORERule2.2.0.wsdl www.caqh.org/SOAP/WSDL/CORERule2.2.0.xsd)

Is there a tool to generate c# classes in dot net? I am using VS2012 and dot net framework 4.0. My background is in Java and I have done this before using tools like Axis2 wsdl2java with appropriate switches. My goal is to get a skeleton interfaces and classes decorated with required annotations that is defined in the wsdl and xsd. Then I can fill in the methods and business logic. I have seen some online posts that mentions the use of svcutil.exe but all of them addresses how to generate a client code not the web service code.

like image 413
Ali Yilmaz Avatar asked May 26 '14 06:05

Ali Yilmaz


1 Answers

You can also use svcutil.exe.

I downloaded the wsdl and xsd and run this command

svcutil.exe /t:code /serviceContract /out:"c:\core\myservice.cs" "c:\core\*"

It generated interface and request/response classes. The only thing is to make a class that implements this interface. Look at default wcf application project type for example.

You can experiment with svcutil.exe parameters further. It can for example generate also a wcf client and config file with bindings. Look at the documentation I mentioned at the beginning of the post.

like image 191
pepo Avatar answered Sep 23 '22 19:09

pepo