There is no doubt about my first love for SAP and it’s techno-functional maturity. I am not frequent writer on SCN because of paucity of time and some other priorities on stack. But whenever there is pain I always come back to SCN for help and usually saved by defeat. I thought, I should also contribute. I cannot contribute like Masayuki Sekihara (He is guide, philosopher and friend for all Fiori Developers), but I can take some small baby steps. I am sure Masa should be much busier than me but still contribute to community and always available to help people like me (Who are little selfish, come back to SCN, when in trouble only). So this triggers a thought for payback to community, whatever big or small I have to share. So here I am with small blog talking about “Proxy  Settings in Fiori/UI5 App”.

So basically proxy settings are required to enable local development or Fiori/UI5 app in Eclipse on desktop with access to the OData Service. If you are testing locally in your Java Eclipse environment and you want to access an OData service in the ABAP system, a proxy is needed to ensure the same origin policy. In an SAPUI5 application project you can use a SimpleProxyServlet for local testing. So below are the required changes:


Step-1:

Open the web.xml file located in the <WebContent folder name>/WEB-INF folder and configure the parameter com.sap.ui5.proxy.REMOTE_LOCATION of the SimpleProxyServlet where the placeholders {protocol}, {host name}, {port number} are to be exchanged by the real protocol, host name and port number:

<servlet>

<servlet-name>SimpleProxyServlet</servlet-name>

<servlet-class>com.sap.ui5.proxy.SimpleProxyServlet</servlet-class>

</servlet>

<servlet-mapping>

  <servlet-name>SimpleProxyServlet</servlet-name>

  <url-pattern>/proxy/*</url-pattern>

</servlet-mapping>

<context-param>

  <param-name>com.sap.ui5.proxy.REMOTE_LOCATION</param-name>

  <param-value>{protocol}://{host name}:{port number}</param-value>

</context-param>

Example for above:

<context-param>

  <param-name>com.sap.ui5.proxy.REMOTE_LOCATION</param-name>

  <param-value>http://abc.com:8000</param-value>

</context-param>

Step-2

Open “Configuration.js”, in case of Fiori and prefix the serviceURL with /approot/proxy (Below is the example code of CRM Fiori “My Leads”)

     sap.ca.scfld.md.ConfigurationBase.extend(“cus.crm.lead.Configuration”, {

            oServiceParams: {

                serviceList: [

                 {

                     name: “CRM_LEAD”,

                     masterCollection: “Leads”,

                     serviceUrl:URI(“CRM_LEADS/proxy/sap/opu/odata/sap/CRM_LEAD/”).directory(),

                     isDefault: true,

                     countSupported : false,

                     mockedDataSource: “/cus.crm.lead/model/metadata.xml”

                 }

               ]

      },

I hope someone will get the benefit of above.


Thanks,

Hemendra

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply