Calling web service from a silverlight client (where to put the clientaccesspolicy.xml file?)

larsile's picture
Calling a web service from silverlight is regarded as cross-domain access and requires a clientaccesspolicy.xml file on the server, which can be read by the client. Deploying an Axis2 web service on Tomcat requires the file to be put in the root directory. In WSO2 WSAS however, we have tried to put the file inside the aar file, in the root folder of the wsas and in the conf directory. None of these solutions have given any results. It seems that the only solution is to deploy to Tomcat instead, but if anybody has ideas I will really appreciate it. Kind regards, Lars
vr.certi.org.br's picture

Adobe Flex/Flash also

Adobe Flex/Flash also requires this crossdomain.xml file at the server. How to tell wso2-wsas to "serve" a regular xml file? Putting it at ROOT doesn´t help, as Lars pointed out. Acording to adobes´ docs, the crossdomain file should be available at: https://my.ip.address:9763/crossdomain.xml that is, protocol://IP:PORT should be exactly the same as the required web-services, and the file must be at ROOT level. However, the above address redirects to carbon´s admin console. any thoughts!? :-) thank you very much
phanquanthien.yahoo.com's picture

The same problem

I also have the same problem. calling wso2 data service from silverlight application, it requires that the clientaccesspolicy.xml file have to be put at the root but i don't know where to put it when using wso2 data service. anyone help me ?. Thank you very much
vr.certi.org.br's picture

smarty workaround :-)

Unfortunately no exact solution found :-( BUT... you could workaround with a proxy. for example, myproxy:9999/*services* --> points to wso2 myproxy:9999/*crossdomain* --> points to a crossdomain.xml file hosted in apache httpd or tomcat you may need a "fake" (tweaked) wsdl file, where all references to wso2's host and port are replaced by the proxy's host and port (in the example, myproxy:9999), otherwise silverlight/flex would get confused (when retrieving a real wsdl, it would attempt to access services through real address, not through proxy, causing crossdomain security fault). in this case, the fake wsdl would also be hosted in httpd or tomcat, with a new directive in proxy: myproxy:9999/*MYSERVICENAME?wsdl* --> points to the faked wsdl (a file MYSERVICENAME with no ?wsdl in its filename does the job) not exactly the most elegant solution, hope it helps :-D
phanquanthien.yahoo.com's picture

Thanks for your quick reply,

Thanks for your quick reply, i don't know exactly how to do as you suggest :(. anyway, thank you very much
vr.certi.org.br's picture

not so quickly

hello sorry, i didn't mean it was easy! it took me about a whole day, after a friend helped me to setup the proxy, so please be patient :-) the commands i typed before are not exact commands, they are only indications of what you should do. i assume you have an application already working at your local computer (flex or silverlight IDE), and that you already imported the original web-references (wsdl) in your application. if that is not the case, you still have hard work to do! with flex, everything runs very perfectly when inside the Builder, in Debug mode, so it is not a problem. Problems begin when you "release" it online or run it from a different folder. sorry, never used silverlight, but it is the same issue we're dealing here... now, if you really really need wso2 runninng online from flex or silverlight, you will need to: 1- know how "crossdomain" or client access policy XML files work (they must be exactly in same domain and port as the service's domain and port, or at least your application must "think" they are) 2- host the required crossdomain.xml or clientaccesspolicy.xml file in a SEPARATE http server (using apache httpd, iis, tomcat or whatever), which can be located at the same machine. 3- learn how to setup a proxy, and start it, lets say at port YYYY. In linux, squid is a very popular proxy. Maybe you can ask a friend to help you setting up squid :-) 4- using the proxy, redirect every HTTP request at YYYY, that contains "services", to the wso2 server (http://xxx:nnn/services where xxx is wso2 host name and nnn is wso2 port). i'm not an expert about proxies, please look at the appropriate docs when in doubt. 5- using the proxy, redirect every HTTP request at YYYY, that contains "/crossdomain.xml" or "/clientaccesspolicy.xml", to the hosted xml file in the Separate server (http://zzz/crossdomain.xml or http://zzz/clientaccesspolicy.xml where zzz is hostname for apache, iis or tomcat, whatever is your separate server) 6- change ALL references in your application from http://xxx:nnn/services/ to http://ppp:YYYY/services/, where ppp is the proxy host name (note also the different port used by the proxy). 6.1 you MAY need to manually hand code the new url inside a WSDL file, as explained before... this is not the hardest step. ;-) 6.1.1. if that is the case, similarly redirect http://ppp:YYYY/services/MYSERVICE?wsdl to the new, tweaked file, which you must host at a http server. naturally, MYSERVICE is the service's name. 7. shake well and reboot as needed!! :-) well, personally this is not a FIX, it is a WORKAROUND. if you are really troubled by this, please post a Bug Report to wso2 team. hope all gets fine... victor
vr.certi.org.br's picture

one last note

I just thought that there is a Workaround to the workaround, :-) since you can host Static files inside "docs" folder of wso2, you don't need a separate http server for xml and wsdl. all other steps apply... well... the best way would be to discover what causes that behavior, and fix that in wso2, but that would be beyond my current capabilities. greetings
ioaalto's picture

Working solution for WSO2ESB if that helps

Hello all, what I did with WSO2ESB was go and modify: wso2esb/webapps/ROOT/web.xml with what is attached. I don't know if there is something similar(probably as there is Carbon involved) in WSO2 WSAS. In addition to the new Servlet you also need crossdomain.xml (or whatever it is in Silverlight) in either: wso2esb/webapps/ROOT/WEB-INF/classes or WEB-INF/lib (modify for WSAS accordingly) This seemed to, at least with a quick try, work and offer crossdomain.xml correctly from the root. Regards, Ilari
phanquanthien.yahoo.com's picture

I will try your solution in

I will try your solution in another day, currently i do not have enough time so my solution is, deploying wso2 data service on Tomcat (reference http://wso2.org/library/knowledge-base/setup-wsas-3-0-apache-tomcat) and put clientaccesspolicy.xml int the ROOT folder of tomcat and my silverlight application have got data from wso2 successfully. Thank you very very much for all your reply.
vr.certi.org.br's picture

please post the attach again, it disappeared

hello, where is the attached file? i swear it was ther 5 days ago :-| please, would you mind posting it in the message text? thank you very much
marty.richard.vrmtechnologies.com's picture

Soltion Needed

Hi, would you mind sending me the solutions you had come up for serving the crossdomain.xml?
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)