Insights on Software Development and Architecture

ErionPC's weblog on software development

Tag Archives: Java

Silverlight and JAX-WS Web Services?

This is a tough one,

for the last two days I’ve been trying to make a Silverlight client consume a Glassfish JAX-WS Web Service, but without any success till a few hours ago. I tried the procedure indicated at “Call a Java EE Web service from Silverlight Client” on the MSDN blogs (the only one I could find) but it didn’t work. That blog post says that the solution is copying an xml file called clientaccesspolicy.xml in the docroot folder of the GlassFish domain where the web service resides. I found that when you add a GlassFish WS web reference to a Silverlight project, Visual Studio (I use the Professional 2008 version) creates a configuration file that gives compilation problems, unless you manually change the “customBinding” to “basicHttpBinding” and manually add the endpoint. When I ran the Silverlight client it launched a CommunicationException due to a “cross-domain configuration error”. I had already copied the clientaccesspolicy.xml file on the docroot folder of my GlassFish domain as indicated on the msdn blog.

Then, after some hours, I had the idea of creating an ASPNET Web Service which acts as a wrapper for my GlassFish WS, but I found out that neither that would work and it would launch the same exception! I started to have strong suspicions that this was a Silverlight bug. I completely erased the existing project which didn’t work and created a new one, adding the web references normally (not manually). In this way it finally worked!

Just out of curiosity I tried adding another web reference to the Silverlight project to my original GlassFish WS, having to change the configuration file manually as before. It not only didn’t work, but it also caused the other (.NET) web service to stop working, even after I had removed it completely and had restored the configuration file to the original state. It’s so ridiculous! Silverlight is good looking, but still not serious enough for interoperability.