cancel
Showing results for 
Search instead for 
Did you mean: 

/uilib-sample/proxy in the TDG demo

Former Member
0 Kudos

Hi all,

I've tried to create the Best Practices Demo as described in https://sapui5.hana.ondemand.com/sdk/#docs/guide/170638b7a2b4424e8580fb473af6a3cd.html in the Developer Guide. However, the code snippet

config : {
            resourceBundle : "i18n/messageBundle.properties",
            serviceConfig : {
                name : "Northwind",
                serviceUrl : "/uilib-sample/proxy/http/services.odata.org/V2/(S(sapuidemotdg))/OData/OData.svc/"
            }
        },

expects /uilib-sample/proxy... to be a valid URL on Hana, but unfortunately, at least in our Hana, it is not. This should work as a proxy to odata.org because direct connection is no allowed due to CORS limitations. Where does /uilib-sample come from, is this some external package or is it part of NetWeaver or similar? Can the demo be constructed without it? Or is it possible to get it somewhere?

Cheers,

-- Micha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Micha,

I had the same problem and found the solution for getting this to work on your local machine. You have to make use of the "SimpleProxyServlet" you find in the web.xml. I'm assuming you're working with Eclipse to create the demo app...

In web.xml you have to add some code below the following part that's already there:

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

Now just below you add the following lines:

<context-param>
<param-name>com.sap.ui5.proxy.REMOTE_LOCATION</param-name>
<param-value>http://services.odata.org:80</param-value>
</context-param>

I am not entirely sure what this does but I think this allows the app to connect to this remote server, because the proxyServlet only works for this url (I tried google.com but this redirects me instead)

Now in the Component.js you have to adapt the serviceUrl as well (you could write some conditional code if you want to run this on a Netweaver system too)

serviceConfig: {

  name : "Northwind",

  serviceUrl: "proxy/http/services.odata.org/V2/(S(sapuidemotdg))/OData/OData.svc/"

  }

This did the trick for me. You can test this by invoking http://localhost:50085/DemoApp/proxy/http/services.odata.org in a browser (replace the port nr. by the port Eclipse is actually using)

I hope this helps!

Regards,

Gert

EDIT: If you're behind a proxy server it might not work and you've to adapt Eclipse's settings under General > Network Connections and add your proxy server config.

Former Member
0 Kudos

hi,

Gert Vermeersch


Can you please tell how to do it in intellij IDE









Regards,

Ajaay

Former Member
0 Kudos

Hi Ajaay,

As far as I know, SAPUI5 development is only supported in Eclipse IDE with the SAP HANA tools add-on. I don't know if the SimpleProxyServlet is bound to Eclipse config or not, it might be possible, but I don't know...

Regards,

Gert

Former Member
0 Kudos

thanks for your reply.

Former Member
0 Kudos

Really helpful and useful note, it solved my issue. Thanks a lot!

Regards, Charlie

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I also got stuck at this point in the Best Practices Demo.

Can anybody help please?

Regards,

Michael