Are there any tool which can generate DTOs which has been decorated with the WCF attributes using a XSD file?
Would be great when migrating from an traditional ASMX service to a WCF service.
Add the XmlSerializerFormat attribute to your service contract, then you can use your existing ASMX DTOs unchanged.
Related
I have some classes (models) and WCF webservices. Can you tell me, how to from these sources generate wsdl file and xsd file ?
To generate the WSDL you first need to expose it in the service by means of the HttpGetEnabled property of the ServiceMetadata behavior.
Put the following in your .config file
Once the WCF service is capable of exposing WSDL, you can get it by appending a '?wsdl' to your service url. For example:
http://localhost/Service.svc?wsdl
Once you can access the WSDL, you can generate a WCF client by using the ServiceModel Metadata Utility Tool (svcutil.exe)
I am creating an ASP.NET MVC 4 application that relies on a WCF service for its BL.
The WCF reference file that was created holds all the data contracts with the service.
I would like to expose the data contracts to the end clients of my MVC application.
Should I use the data contracts in my controllers instead of creating models?
My end client needs JSON format responses. How can I decorate the data contract references with
JSON attributes so it will get serialized the way I want it?
Decorate your data contract with [DataContract] and decorate your operation contract for example with
[WebGet(UriTemplate='...', ResponseFormat=WebMessageFormat.Json]
The last part will make WCF use the JSON serializer.
I think we have found a solution to the problem, our front end team is now sharing contracts with backend WCF service this is actually replacing our models in the MVC application (not all of theme but most of theme). We can decorate our contracts as we like and we take the benifit of both worlds. #Suhani Mody
I have a WCF service. Contract for the service is defined using interface. The implementation is not yet created. I need to create WSDL and XSD corresponding to the contract. I will deliver the soforth generated wsdl to my team members. They must be able to create the interface from the wsdl and create the service. What are the approaches/tools for creating the wsdl and xsd from the C# interface which is used as the contract? Also, how to create the interface back from the WSDL? Do I need to provide both the xsd and wsdl to the developers or only the WSDL?
What is the best approach for WSDL interoperability?
Note: I have two services. One uses Data Contract. Second one uses Message Contract.
Note: I am using Visual Studio 2010 and .NEt 4.0
Reading:-
Generating a WSDL from an XSD file
Can you combine the WSDL and XSD data from a WCF service?
What tool can I use to merge wsdl and xsd file?
Providing the WSDL should be enough as the WSDL would have the reference to the xsd's using the import attribute.
When defining your bindings for your WCF service make sure you use BasicHttpBinding (follows BasicProfile 1.1) which is interoperable.
Also you would consider flattening your WSDL for your service to be highly interoperable as at times php and other java clients might need flat wsdl. If you are using .NET 4.5 then you have this as an inbuild option now else you can check this link on how to flatten your wsdl
I want to architecture our software so that we can expose our API logic using WCF (SOAP and REST).
Im confused as to whether I have to use ASMX files if I want to do SOAP services, or whether .svc file can still do SOAP service?
Yes you can. You have to expose a SOAP end-point for your WCF service. This MSDN post has an example.
Your svc file can provide the restful interface you are requesting. You just have to do a little configuring within your web configuration file, and decorate the svc class with the attributes to describe the behavior of our restful url.
here is a great article going over the steps:
http://www.dotnetfunda.com/articles/show/779/simple-5-steps-to-expose-wcf-services-using-rest-style
You are given a WSDL and a sample soap message, is there a good tutorial or sample code in using that WSDL to consume a web service? Does the WSDL follow a certain format in order for which it can be consumed properly? I recall a web service in Java that I changed certain tags and attributes in order for this to work, is there a general convention for the formatting used in WSDLs?
I think this might be harder than #1. You are given a WSDL and a sample soap message. Is there a way to use that given WSDL and not the WSDL generated by C# web service when exposing a web service? Is there a way to somehow "override" the WSDL of the web service to the given web service? Are there any conflicts in formatting and compatibility of the WSDL that ought to be considered?
The quickest and most painless approach is simply to use svcutil to generate the code representing the WSDL. At that point the code produced can be used as a client to query an existing service or you can define a class implemeting the service contact. Once you have the .NET classes the SOAP message example will just serve as documentation.
the default usage would be want you most likely want
svcutil myRemoteService.wsdl
which will generate a a file named [servicename].CS file and an output.config containing the necessary WCF client bindings.
Not sure what you mean by overriding the WSDL as it is the published contract that the service honors. So if you want to change method signatures or behavior it will no longer work as the change will no longer conform to the WSDL.