I have a java servlet with the OData4j library and I want to configure it so I can make HTTP POST request from a Silverlight application.
My web.xml file looks like this:
<servlet>
<servlet-name>OData</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>org.odata4j.producer.resources.ODataResourceConfig</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>OData</servlet-name>
<url-pattern>/myService/*</url-pattern>
</servlet-mapping>
I've tried adding this to my web.xml file:
<servlet>
<servlet-name>CrossDomain</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>org.odata4j.producer.resources.CrossDomainResourceConfig</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CrossDomain</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
But it doesn't work. I also tried adding the "crossdomain.xml" and "clientaccesspolicy.xml" files to my resources directory but that also doesn't work. I still get a SecurityException when sending a HTTP POST request with my Silverlight application.
Any hints would be greatly appreciated.
Thanks
Turns out that instantiating CrossDomainResourceConfig does enable the "crossdomain.xml" and "clientaccesspolicy.xml" files. The thing is that they are available at the URL: /myService/crossdomain.xml
and /myService/clientaccesspolicy.xml
.
However, the Silverlight runtime looks for those files at the server root (eg: /clientaccesspolicy.xml
)
By adding both of those files manually in the server root, it fixed the problem.