Last post Oct 28, 2013 12:16 AM by ramana123
Oct 24, 2013 07:30 AM|ramana123|LINK
Hi new to WCF world but familiar with ASMX.
I have a situation here like..
Need a WCF service which takes a input and perform some actions based on the input data like get the files and store it in a location for another service.
input will have several paramters like file name, size, location, etc but the point is this WCF will be used in classic ASP as well along with other .NET apps.
So, I am thinkning should I go with Message contract or Data contract. and how about bindings should it be differebnt based on contract?
or will it be possible without any contract as just passing XML as a paramter to operation contract like ASMX web method? [I like this bcoz of classic asp clients eixsts]
Oct 24, 2013 08:44 AM|Siva Krishna Macha|LINK
Based on your requirement, I think, the best suitable option for you is to use - basicHttpBinding,
It will have input as xml and gives response also in xml - you can observe it if you enable tracing. i.e., it will accept the objects as the input but under the hood, it will be converted to xmls.
How to create WCF service to use basicHttpBinding? - Refer this link
Note: You may not need Step 3 and Step 4 in that article.
Also, DataContract would be simpler to use, instead of MessageContracts. We need to use MessageContract only when we want to incorporate certain SOAP similar futures in our service. Refer the link:
Please mark this as answer if this answers your question.
Oct 25, 2013 12:27 AM|ramana123|LINK
Thanks Siva for the response.
you mean define Operation contract which takes input as string paramter and send XML in it as a input? pls clarify.
Also, what if we need to later add authentication into this service as username and pwd sort of?
Oct 25, 2013 05:58 AM|Siva Krishna Macha|LINK
You are welcome, Ram.
Yes. We need to define an OperationContract that can accept an object (just like normal methods).
This can then be consumed by clients in two ways:
1. Use proxy, fill the objects and call as if it is a normal method. (But on the background, dotnet will convert the object to xml for processing)
2. We can simply construct the plain xml and send it as a HttpRequest. I've not tried this option but can be done.it wo
Prefer the 1st option, as it would be easier to construct the objects than the xml manually.
Please let me know if any other questions. Suggest to go through some How-To articles on WCF to understand this still better.
Oct 28, 2013 12:16 AM|ramana123|LINK
Thanks I did it with Message Contract so that I was able to send the required authentication info as well in request from clients..