This is the second example project in this series and is based off of the first example. This is a complete example of WCF using OO principles that leverage the NetDataContractSerializer. This example goes along with the content found here. The zip file contains the following projects:
ExampleTwo.zip You should be able to download the zip file, unzip it, open up the solution, and build it without a problem. To test the application, set the WcfServiceHost as the startup project and run, and then set the WcfClient project to the startup project before running.
| Attachment | Size |
|---|---|
| ExampleTwo.zip | 584.54 KB |
Comments
Hi,
What about returning an Interface?
I have somehting like that:
[OperationContract]
IService GetService(string serviceName);
But always getting this exception when calling the method from the client:
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9531250'.
Is it possible to return an Interface from a WCF method?
Regards,
Benoit.
Yes, it is definitely possible. It's been a while since I've written the examples, but I thought I did return an interface in, maybe, Example Three?
Regardless, the error you are receiving is not due to returning an interface...unless you are not using the NetDataContractSerializer and/or you are not using a .NET client. It's too hard for me to say exactly what is going on in your case without digging into the code.
We would really like to see the example of returning an interface through a WCF method. Can you post this (example three?)?
Thank you!
I have followed your example - thank you very much for the example and the article very handy.
however I am getting this error do you know this error is due to what?
There was an error while trying to serialize parameter http://tempuri.org/:person. The InnerException message was 'Type 'Domain.Customer' with data contract name 'Customer:http://schemas.datacontract.org/2004/07/Domain' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details.
any feedback will be appriciated
You're welcome.
Are you getting this error when running the example? Just a moment ago I downloaded the example and ran without a problem. Are you instead getting this error after tweaking the example code or perhaps in your own project?
The error above signifies that you are using the DataContractSerializer instead of the NetDataContractSerializer, perhaps by accident.
I got the program working now it was just a mistake in the NetDataContractSeriliaser file - its just whe you press the enter key after the word implements when a class implement a service) it generate function - I had my owen function and VB genetrated automatic function which confused the program
thank you again for the example
do you have an Idea on how we can apply the NetdataContractseriliazer only once at the service contract level instead of decorating each operation inside the service with the NetDataContractSerializer
found some example here but i did not get it to work sofare
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2329202&SiteID=1&p...