The Adobe cross-domain policy file: http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html has to be located in the root folder of your application server. For the ABAP Web AS it is not so easy to place file into the root folder. One option is to use a default service (e.g. BSP) and place the file into the mime repository of this BSP. But what if you also want to have a “real” default service? Here I would like to show you a different method what eliminates this issue, and is simple to implement.
h3. Crossdomain.xml in the ICM Server cache
We will use the caching mechanism of the ICM to store the file for us in the root folder. We upload the file in a periodic job every day, and let the ICM will keep the file for us for a day in the cache.
Here is the code you can use in your report. You only need to modify the ‘concatenate’ section with the content of your crossdomain.xml file.
<br />”Create the Crossdomain.xml<br />”
DATA crossdomainxml_t type string.
DATA crossdomainxml type xstring.
‘<?xml version=”1.0″ encoding=”UTF-8″ ?>’
‘<allow-access-from domain=”mydomain.com” /> ‘
‘<site-control permitted-cross-domain-policies=”master-only” />’
‘<allow-http-request-headers-from domain=”.mydomain.com” headers=”” secure=”true” />’
into crossdomainxml_t SEPARATED BY SPACE.
“convert to binary
CALL FUNCTION ‘SCMS_STRING_TO_XSTRING’
TEXT = crossdomainxml_t
BUFFER = crossdomainxml
” Create Response object with the crossdomain data”
data lr_cached_response type ref to if_http_response. create object lr_cached_response type cl_http_response exporting add_c_msg = 1. lr_cached_response->set_data( crossdomainxml ). lr_cached_response->set_content_type( ‘text/xml’ ). lr_cached_response->set_status( code = 200 reason = ‘OK’ ). “set the validity for more than a day(86400) lr_cached_response->server_cache_expire_rel( expires_rel = 90000 ).
“Upload to the ICM root directory”
CALL METHOD CL_HTTP_SERVER=>SERVER_CACHE_UPLOAD
URL = ‘/crossdomain.xml’
RESPONSE = lr_cached_response
SCOPE = IHTTP_INV_GLOBAL
Creating a background job to upload the file into the cache.
- Start Tr. SM36 and start the Job wizard and select ‘Continue’
- Enter Job Name ( I used ZCROSSDOMAIN. ) and hit ‘Continue’.
- Select ABAP Program Step and again ‘Continue’
- As ABAP Program name enter the name of the program you have just created. Click ‘Continue’. No additional steps are necessary for our job, so select again ‘Continue’.
- Select ‘Date / Time’ as start condition. Click ‘Continue’
- On the next screen you can enter 1:00 AM the next day as start time and select the flag for periodic job. Click ‘Continue’
- Select Daily on the next screen. Click ‘Continue’
- Click ‘Complete’
Now you have a job that will upload the file into the server cache every day. Only thing you have to take care about: Run the report after you have restarted the ICM or deleted the ICM cache.