Hi guys,
I'm learning to develop UI5 application. I have my application hosted at localhost via tomcat.
In the application, I'll need to fetch some data from internet odata service: http://services.odata.org/Northwind/Northwind.svc/.
So when I do local testing, I'll need the simple proxy servlet to help avoid cross origin access issue.
I read the help document: Use a SimpleProxyServlet for Testing to Avoid Cross-domain Requests
https://help.sap.com/saphelp_nw74/helpdata/en/2d/3f5fb63a2f4090942375df80abc39f/content.htm
So I configure the web.xml as following:
<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>http://services.odata.org</param-value>
</context-param>
But when I fire the request, I got the error of java.net.UnknownHostException: services.odata.org
2014-08-10 19:13:10 The following problem occurred: HTTP request failed500,Internal Server Error,<html><head><title>Apache Tomcat/7.0.54 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - services.odata.org</h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u>services.odata.org</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.net.UnknownHostException: services.odata.org java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) java.net.Socket.connect(Socket.java:579) java.net.Socket.connect(Socket.java:528) sun.net.NetworkClient.doConnect(NetworkClient.java:180) sun.net.www.http.HttpClient.openServer(HttpClient.java:432) sun.net.www.http.HttpClient.openServer(HttpClient.java:527) sun.net.www.http.HttpClient.<init>(HttpClient.java:211) sun.net.www.http.HttpClient.New(HttpClient.java:308) sun.net.www.http.HttpClient.New(HttpClient.java:326) sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996) sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932) sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850) com.sap.ui5.proxy.SimpleProxyServlet.service(SimpleProxyServlet.java:216) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) </pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.54 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.54</h3></body></html>
I'm testing my application behind a corporate proxy. So I've configured the eclipse proxy properly.
1st Question: what's the problem here? Can someone advise where I'm doing wrong?
Another thing is If I remove the com.sap.ui5.proxy.REMOTE_LOCATION configuration in the web.xml, and I access the intranet odata service instead of internet service. everything works fine.
2nd Question: what's the usage of com.sap.ui5.proxy.REMOTE_LOCATION configuration ? Even if I don't do configuration for com.sap.ui5.proxy.REMOTE_LOCATION, I still can access the intranet odata service correctly?
3rd Question: How do I configure simple proxy servlet to have more than one remote location? that is, I have both internet and intranet odata service to access, how to do configuration for that?