Skip to main content
Home Forums Silverlight Programming Accessing Web Services with Silverlight Sharing types between two web services
4 replies. Latest Post by sivaselvan on November 12, 2009.
(0)
moorster
Member
8 points
13 Posts
11-04-2009 4:48 PM |
I need to access two web services from my Silverlight app. Both web services have 90% of their types in common. Can I use some sort of switch like 'sharetypes' to force the classes that are in common be generated on the client only once? Right now each service reference has its own copy of all the server classes in its own namespace.
MyMindsOwn
52 points
22 Posts
11-04-2009 5:27 PM |
I don't think so. But you could create a facade service in your site of origin that is a composite of both service contracts and use that as your sole service reference in Silverlight.
11-04-2009 7:19 PM |
That is a possibility. My sites happen to be Java applications and I don't have full control over them. I could make a third site that acts as a facade, as you suggested. However, I know the ability to combine service types exists for non-silverlight, regular c# clients. There must be a way to do it with Silverlight as well.
11-10-2009 5:54 PM |
Ok, I stumbled upon this link and I think it answers my question.
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=426791
If you have more than once service you would first establish a ServiceReference to one of your services. Then you can modify the Reference.svcmap that was created for you. (If you are using VisualWebDveleoper 08 and you don't see it under the ServiceReference you created then make sure "Show All" is checked for your project.) In the Reference.svcmap, you can then add as many MetadataSource files as you want for your additional services. Make sure they each have a unique SourceID. Then right-click your service reference and choose Update to have VisualStudio (or VWD) pull down the metadata for all services.
Using this method appears to share types nicely between services on the client side as long as the types are defined in the same namespace on the server side. I'm using java's jax-ws for my web services so I had to set a @XmlType and specify the namespace for all of my classes and enums on the server.
sivaselvan
2 points
1 Posts
11-12-2009 2:54 AM |
Great Answer! It saved lot of time! Thanks lot.