简体   繁体   中英

Best way to create WCF “server side code” service from existing WSDL

I have an existing wsdl and xsd files. Now, i want to create WCF "server side code" service based on existing WSDL. I know that svcutil.exe generates host (client side) code. I don't want client side. Please, could any one help me ?.

You could try svcutil with /out: option for this purposes.

There is one more old sample here

Use xsd /c /l:cs /n:Namespace.You.Want FilenameRequest.xsd FilenameResponse.xsd

to generate c# classes with the agreed XML contract. You will have something like ResponseClass.cs and RequestClass.cs

Then create your service passing generated Request class as message parameter. Forcing service to use XmlSerializer instead of DataContractSerializer . Something like this:

[ServiceContract, XmlSerializerFormat(Style = OperationFormatStyle.Document, 
    Use = OperationFormatUse.Literal)]
public interface IService
{
    [OperationContract()]
    ResponseClass YourRequestOperation(
        [MessageParameter(Name="NameInAgreedContract")] RequestClass rq);
}

Then create an implementation of the interface. Deploy it. Profit.

In my case, the client would result in a very specific wsdl file he gave me with other xsd files where the class definition is. I just want the structure of the interface headers (System.SerializableAttribute, XmlTypeAttribute ...) because DataContract and DataMember not given results in the wsdl file. when I use svcutil, I just aligned a little bit with the wsdl file but differences remain as binding, port name. also things prefix like "intf" instead of "tns".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM