April 23, 2010 11:01 by
bryan
WCF is a very powerful tool for developers, and I'm sure as you dive in to the development environment you will come across the WCF Message, which is part of System.ServiceModel.Channels Namespace. You should be aware that a message body can only be accessed once and a message can only be written once. This will in turn can cause a problem if you are creating your own IDispatchMessageInspector, as at some you will need to read the message and once you have read it, you are buggered!
So in order to use the Message you will have to copy the message in to a buffer using the CreateBufferCopy method, here is how you go about it
public void Validate(ref Message message)
{
MessageBuffer buffer = message.CreateBufferedCopy(int.MaxValue);
try
{
ValidateInput(buffer.CreateMessage());
}
catch (Exception)
{
throw;
}
message = buffer.CreateMessage();
}
bc195e45-58fd-41ed-9d3f-19144b0dd93d|1|1.0
April 16, 2010 14:54 by
bryan
I've been dealing with REST services within WCF, and one thing that has come to my attention is that the calling service or third party only has access to the REST interface and the XSD's.
The XSD's holds all the contract information, therefore if you need to generate a concrete class you are going to have to translate the XSD to an object.
I've have come across the XSD Object Generator frm Microsoft which appears to do the job.
bec3b72b-a782-4f9b-bdd7-38a8ed76305d|1|1.0
April 6, 2010 09:43 by
bryan
When using WCF and Rest one thing you're going to have to consider is the validation of the object, the way to do this is using the Validation Application Block included in the Microsoft Enterprise Library to validate the data transfer objects. This way you can decorate the objects with attributes to validated the objects
Here is an example
public static void Validate<T>(T obj)
{
ValidationResults results = Validation.Validate(obj);
if (!results.IsValid)
string[] errors = results
.Select(r => r.Message)
.ToArray();
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.BadRequest;
WebOperationContext.Current.OutgoingResponse.StatusDescription = String.Concat(errors);
}
thanks to Enrico Campidoglio for helping out on this
626328eb-3b9a-45f0-8bec-c40da8595bf9|2|1.0
March 23, 2010 11:26 by
bryan
2f795fde-d207-4a50-99c6-84b7c4dc2447|1|1.0
March 11, 2009 16:04 by
bryan
After looking around and playing with WCF for a while, it had come to my notice that all the examples that I could find were over complex, then I came across Ralf's Sudelbücher blog entry for "A truely simple example to get started with WCF", so simple, so to help you along here is the C# source code that I have written, with a few additions in that the solution also has a client console that calls the WCF application to show a true sence of what is happening.
SimpleWCF.zip (21.68 kb)
d5e7f40e-bbe7-4dcc-9262-fc73ccac801a|0|.0
January 24, 2009 22:39 by
bryan
d7ffcefa-34e5-4fa9-bf0d-703a2164d4c6|0|.0