5

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.

Ali Yilmaz
  • 51
  • 1
  • 1
  • 3
  • You can take a look at [WSCF.blue](http://wscfblue.codeplex.com/), but it looks like it hasn't been updated in about 3 years. – Tim May 26 '14 at 06:51
  • possible duplicate SO http://stackoverflow.com/questions/950150/how-to-use-a-wsdl-file-to-create-a-wcf-service-not-make-a-call How to use a WSDL file to create a WCF service (not make a call) – david.barkhuizen Jul 08 '16 at 09:03

1 Answers1

5

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.

pepo
  • 8,644
  • 2
  • 27
  • 42
  • Thanks. I ran the command svcutil.exe /t:code "C:\core\CORERule2.2.0.wsdl" /out:"C:\core\myservice.cs" "C:\core\*" and it generated the interfaces and the classes. I am missing annotations such as [ServiceContract] [OperationContract] [DataContract] [DataMember] in the class file. Do I have to provide additional switches for those or are those meant to be entered manually? – Ali Yilmaz May 26 '14 at 17:59
  • 1
    There is an operationcontract attribute set on every method in th e interface. Servicecontract attribute is also set on interface. DataContract and datamember attributes are not there because xmlserializer is used for serialization and deserialization of requests and responses. I don't think that using xmlserializer will be a problem, in some cases it is even useful to use it instead of datacontract serializer. – pepo May 27 '14 at 06:58