Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member191062
Active Contributor

Introduction


 

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.
REPORT ZCROSSDOMAIN.

"--




<br />"Create the Crossdomain.xml<br />"




DATA crossdomainxml_t type string.

DATA crossdomainxml   type xstring.

CONCATENATE

'<?xml version="1.0" encoding="UTF-8" ?>'

'<cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'

'xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">'

'<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" />'

'</cross-domain-policy>'

into crossdomainxml_t SEPARATED BY SPACE.

"convert to binary

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

TEXT           = crossdomainxml_t

IMPORTING

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
EXPORTING
URL      = '/crossdomain.xml'
RESPONSE = lr_cached_response
SCOPE    = IHTTP_INV_GLOBAL
.

 

Creating a background job to upload the file into the cache.


    1. Start Tr. SM36 and start the Job wizard and select 'Continue'

    2. Enter Job Name ( I used ZCROSSDOMAIN. ) and hit 'Continue'.

    3. Select ABAP Program Step and again 'Continue'

    4. 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'.

    5. Select 'Date / Time' as start condition. Click 'Continue'

    6. 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'

    7. Select Daily on the next screen. Click 'Continue'

    8. 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.

 

6 Comments