Adsense

Showing posts with label Web Service. Show all posts
Showing posts with label Web Service. Show all posts

Thursday, June 14, 2007

Web Services, IDictionaries and Serialization... Oh My!

I have been building some .Net web services lately and created one that was trying to return a generic IDictionary. (IDictionary<int, int>) To my surprise and ultimate disappointment, I was presented with the following Server Error when trying to access my webservice...

"The type System.Collections.Generic.Dictionary ..<removed babble>.. is not supported because it implements IDictionary."

It looks like the XmlSerializer is unable to serialize objects that implement IDictionary. How annoying! I use a lot of generic dictionaries and it's a bit of a pain work around this XmlSerializer limitation. I was able to find a solution from this Aaron Skonnard post on the msdn site.

The solution shows you how to write a class that actually wraps your dictionary object. The values of your dictionary are copied to an array of serializable objects which are allowed to be passed through your web service and then deserialized on the other end. Pretty handy and worked really well in our solution.

Aaron warns that the IXmlSerializable interface is undocumented/unsupported feature of the .Net Framework and is subject to change at any time.

Tuesday, May 29, 2007

Web Service Security (Invalid URI: The format of the URI could not be determined)

Ran into an issue today while trying to connect to a Java Web Service from a .Net environment. It looks like this happens when Web Service Security is enabled in the application server of the web service and uses the ActorURI attribute. .Net's Web Services Enhancements feature does not support relative URI's for this attribute and basically FUBAR's on you. Therefore, you must us an absolute URI.

An example of an absolute URI is "http://LoginWebService" while an example of a relative URI would be "LoginWebService"... You must configure your Application Server to using either the Rational Application Developer or the Application Server Toolkit.

  1. Open the Web Service Editor, click the Extensions tab and expand Server Service Configuration.
  2. Enter the full absolute URI in the Actor field.
  3. Expand Response Generator Service Configuration Details > Details.
  4. Enter the full absolute URI in the Actor field.

Source