Calling a Java Web service from silverlight throws an exception

前端 未结 1 1326
盖世英雄少女心
盖世英雄少女心 2021-01-17 03:18

After my previous question HERE, I found the solution (well, part of it).

Here\'s the code for Java part:

@WebService

public class

相关标签:
1条回答
  • 2021-01-17 03:32

    I guess you are getting a System.ServiceModel.CommunicationException when trying to access the Java Webservice from Silverlight.

    There is nothing basically wrong with your code, and it should also work with async calls in C# Console App.

    The main problem is that Silverlight (as a browser plugin) enforces some security restrictions that prevent a Silverlight Application to talk to another server than the one loaded from (defined by server name and port) without further configuration. This behaviour can be configured as described here (also search for "silverlight cross-domain calls" or "silverlight cross domain policy").

    This restrictions (normally) do not apply to desktop or console applications so they'll work fine with the same web service.

    To make your code work you need to host the Silverlight Application inside the same "project" / website than your webservice (so I suppose, the self-hosting webservice won't work and you need to switch to Java web project where the webservice is to be hosted). As the Silverlight Application basically consists of an enclosing HTML file plus the referenced binaries, you can host it on any server, e.g. Apache Tomcat.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题