GWT with -noserver

I am making a GWT project that uses PHP to connect to a DB2 database. When I compile the project and deploy it on the server (copy the contents of the WAR directory), it works fine, it is obvious that in the hosting mode I am running the SOP problem, since GWT is on port 8888 and the php script is running on port 80.

I am trying to run the -noserver option, but I am missing something. I came back and created a basic sample application from the command line (webApplicationCreator -out / home / mike / gwt / sample1) I edited build.xml to include the -noserver and -port 80 arguments for devmode. I want my application to be hosted in localhost / sample1, so I edited -startupUrl for the whole URL I want to use: http: //localhost/sample1/sample1.html

I compiled (ant), copied the file sample1.html, sample1.css from war to the webserver directory sample1 and (md5) .gwt.rpc, clear.cache.gif, sample1.nocache.js and hosts.html files from the war / directory sample1 in sample1 / sample1, as described in the GWT documentation (the history.html file was not created). Then I run ant devmode from the project directory (/ home / mike / gwt / sample1) I can go to the sample1.html page, but when I click the button to send the name to the server, it returns with

Remote Procedure Call - Failure

Server responses: An error occurred while trying to contact the server. Check your network connection and try again.

firebug 404 http://localhost/sample1/sample1/greet. .. , , -.. ? , GWT?

- ? !

+3
2

, - . GWT (RPC) , , .

, Java, GreetingService, web.xml, , , , ( ). , , GWT-RPC PHP, URL, GWT RPC .

PHP- , , GWT-RPC, , JSON XML, , RPC .

? .
+4

SOP, HttpProxyServlet HTTP- - .

httpProxyPackage.jar, WEB-INF/lib/ WEB-INF/web.xml ( StockWatcher, , - - , StockWatcher):

<servlet>
  <servlet-name>jsonStockData</servlet-name> 
  <servlet-class>com.jsos.httpproxy.HttpProxyServlet</servlet-class> 
  <init-param> 
    <param-name>host</param-name> 
    <param-value>http://localhost/StockWatcher/war/stockPrices.php</param-value> 
  </init-param> 
</servlet>

<servlet-mapping> 
  <servlet-name>jsonStockData</servlet-name>
  <!--
    http://127.0.0.1:8888/stockPrices.php in dev mode
    http://gwt/StockWatcher/war/stockPrices.php in prod mode
  -->
  <url-pattern>/stockPrices.php</url-pattern>
</servlet-mapping>

URL- JSON :

    GWT.getHostPageBaseURL() + "stockPrices.php?q=";

:

    GWT.getModuleBaseURL() + "stockPrices.php?q=";

, , - ... php-cgi, .

0

Source: https://habr.com/ru/post/1728875/


All Articles