Posts Tagged WCF
UPDATE: MS Tag REST service issues
Posted by suddenelfilio in .net, MSTagLib, Web Services on 03/08/2010
During the last 24 hours the service has been experiencing some issues when called. This has currently been resolved. If you’ve received an http 500 error code when calling the service please try again. The issue was introduced when I extended the service to record certain metrics. These metrics or stats can be seen on http://tag.ws.suddenelfilio.net/ at the end of the page.
If you experience any other problems please contact me at: mstaglib@suddenelfilio.net
MS Tag REST interface updated
Posted by suddenelfilio in MSTagLib, Web Services on 30/07/2010
Today I’ve updated the Microsoft Tag REST interface over at http://tag.ws.suddenelfilio.net/.
Since Microsoft released Tag I was a bit behind to update the interface to include the GetTagID functionality. This is now made up for and the service available for all to enjoy.
I also updated the documentation on how to use the REST interface to get a Tag’s id.
If you experience any problems please let me know using the address that you can find over at http://tag.ws.suddenelfilio.net/ or leave a comment on this page!
MS Tag REST Certificate Issues
Posted by suddenelfilio in .net, MSTagLib, Web & Design, Web Services on 28/04/2010
This week I received an email telling me that they got an error while using the MS Tag REST service:
System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority ‘ws.tag.microsoft.com‘.
As you can see the authority is complaining about the Microsoft domain. The issue was the certificate used by Microsoft’s Tag API was outdated and thus the error was thrown when the REST service communicated with the Microsoft service.
Since the certificate has been renewed and is now valid till somewhere early 2011 this problem should be resolved.
Microsoft Tag Rest API & Silverlight
Posted by suddenelfilio in .net, Asp.net, MSTagLib, Silverlight, Visual Studio .Net, Web Services on 11/03/2010
Recently I was contacted by a developer that was working with my MS Tag REST service. He was was calling the REST API from within silverlight. I helped him out with some questions and in return I got a sample project that I can distribute as reference sample. The sample will allow you to create a vcard Tag from within a silverlight application and then display the generated tag.
Live demo : http://tag.ws.suddenelfilio.net/demo/silverlight/Default.aspx
Source Code: Download
Downloaded 152 times
I would foremost like to thank Brian King for his effort in creating this sample for everyone that is interested in it. If you like it, please leave a comment to thank him!
Compact framework WCF, Disco files, netcfsvcutil
Posted by suddenelfilio in Uncategorized on 06/11/2008
When using the 3.5 version of the compact framework it is possible to connect with wcf services. This is because the CF 3.5 contains a limited subset of the wcf technology. There are several blog posts listing the wcf capabilities in CF e.g.: http://blogs.msdn.com/andrewarnottms/archive/2007/08/21/the-wcf-subset-supported-by-netcf.aspx
We were researching for a mobile client to connect to a wcf service running at one of our servers. The requirement is that transport is secured by using HTTPS protocol.
The first problem was creating a client side proxy. Since the SvcUtil doesn’t work for the CF we had to look for an alternative. After some googling we found the netCFSvcUtil which is basically the same as the svcutil, but it generates a proxy specifically for CF. You can find it as part of the Power Toys for .NET Compact Framework 3.5. For more on this you can read this excellent blog post by Andrew Arnott
When you get this generated client proxy there is another problem. It expects that you are using HTTP. Since we need HTTPS that’s a problem. Thanks to Damir Dobric we found how to make the proxy use https instead of http.
System.ServiceModel.Channels.CustomBinding binding = new System.ServiceModel.Channels.CustomBinding(); binding.Elements.Add(new System.ServiceModel.Channels.TextMessageEncodingBindingElement (System.ServiceModel.Channels.MessageVersion.Soap11, System.Text.Encoding.UTF8)); System.ServiceModel.Channels.HttpsTransportBindingElement https = new System.ServiceModel.Channels.HttpsTransportBindingElement();
https.RequireClientCertificate = false;
binding.Elements.Add(https);
This way your client proxy is now HTTPS enabled.
Another problem we had was that the disco file was downloaded from the “wrong” location. We have a wildcard certificate in place for our HTTPS like *.domain.com. We were accessing the service using https://laptop1.domain.com/wcf/service.svc. Although this url works fine when we browsed to it, there was an issue when we tried to generate a client proxy. It seemed that both svcutil as netcfsvcutil were trying to download the DISCO file from https://laptop1/wcf/service.svc?Disco. When we browsed to this link it worked just fine. The problem is in the url and the wildcard certificate. Since the disco url didn’t include the domain.com part in its url the utils were not able to establish a trust relationship over ssl with the web server. This is perfectly normal since it does not correspond with our wildcard certificate.
The solution is to update the https binding in IIS by giving it a host header. Now this is something you can’t do in the IIS control panel. There are 2 ways of doing this: Using scripting or using the metabase explorer that can be found in the IIS 6.0 resource toolkithttp://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/993a8a36-5761-448f-889e-9ae58d072c09.mspx?mfr=true
A last advice don’t fall into the same trap by thinking that a wshttpbinding is required to do HTTPS, it’s perfectly possible by using a basichttpbinding where the security mode is set to transport.
MSMQ Message priority
Posted by suddenelfilio in Visual Studio .Net on 22/10/2008
In my recent development I’ve been using msmq to store messages that can’t reach a wcf service when it’s not available. I was setting the Message (System.Messaging) property Priority so that the queue would prioritize the incoming messages.
However when I looked at the queue all the messages their priorities where 0 or “Lowest”. It seems to be because my queue is transactional (which is a requirement for the msmqintegrationbinding). It was a bit of a disappointment that I couldn’t control the priority using the native msmq features, but hey that’s the price I had to pay for some other great functionality.
WCF: msmqIntegrationBinding
Posted by suddenelfilio in Visual Studio .Net on 22/10/2008
Today I discovered the msmqintegrationbinding in the windows communication framework.
This binding is especially to allow wcf services to process message that are put in a message queue by some legacy program. The advantage of this is that you can do this without the need to change the legacy client.
If you want more information on how to use this binding have a look at this post at Simon Evan’s blog
There was something I liked in particular and it was exactly what I was looking for; I’m working on a custom logging framework adapted to our needs. To keep it simple let’s say that a Log class sends messages using the fast netnamedpipebinding in wcf to a service. This works fine, but what when the service is unavailable? Well I’ve designed the Log class to automatically failover sending the message it would normally send to the service to a queue. This way I don’t lose any of the log messages. The advantage I mentioned above is that when I reset the service (launch it again) it automatically starts processing the messages (logs) in the queue as well as accepting new log messages using the named pipes. So this way I achieve our main priority: deliver the log messages as fast as possible, but without losing them when the service is down.
Exception serialization & WCF
Posted by suddenelfilio in Uncategorized on 19/01/2007
I was helping a colleague of mine this week with some exception handling in WCF. The problem we were facing was that when we send a faultexception we lost important information about the original exception like the innerexceptions. Although it may not be best practice to send all of the exception information to the client we still wanted to find a way to get this done.
We tried various possibilities and ended up with the binary serialization of the original exception. To send it to the client we converted the serialized exception to a base64 string which is ideal for this sort of scenario’s. Then on the client side we just deserialize the base64 string back into an exception. We still use the WCF faultexception but we use the reason property to store the base64 string for transport.
We also tried the XML serialization but this gave to much trouble on the data property of the exception class because it was marked not-serializable due to the IDictionary interface it implements.
Another thing we looked at was using reflection to rebuilt the exception, but this was too complex and can cause a performance overhead.
Below you can see a sample of the ExceptionFormatter class that we created. Actually it’s nothing more than regular binary serialization with the constraint that the serialized object must implement the ISerializable interface. Oh yes mind the line breaks !
Imports System.Runtime.Serialization.Formatters.Binary Public Class ExceptionFormatter Public Sub New() End Sub Public Function Serialize(ByVal objectToSerialize As Runtime.Serialization.ISerializable) As String Dim formatter As New BinaryFormatter Dim mem As New IO.MemoryStream formatter.Serialize(mem, objectToSerialize) Return Convert.ToBase64String(mem.ToArray) End Function Public Function Deserialize(ByVal base64String As String) As Runtime.Serialization.ISerializable Dim formatter As New BinaryFormatter Return formatter.Deserialize(New IO.MemoryStream( Convert.FromBase64String(base64String))) End Function End Class
