GWT ile-noserver

2 Cevap php

Ben bir DB2 veritabanına bağlanmak için PHP kullanan bir GWT projesi yapıyorum. Ben projeyi derlemek ve (üzerinde WAR dizinin içeriğini kopyalamak) sunucusuna dağıtırken, bu php script noktası üzerinde çalışırken GWT 8888 nolu portu olduğundan ben SOP sorunu içine run ana modda Açıkçası, çalışıyor 80.

I'm trying to get the -noserver option to work but I must be missing something.. I went back and created the basic sample app from the command line (webApplicationCreator -out /home/mike/gwt/sample1) I edited the build.xml to include the -noserver and -port 80 arguements for devmode. I want my app to be hosted at localhost/sample1 so I edited the -startupUrl to the whole URL I want to use: http://localhost/sample1/sample1.html

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

Uzaktan Yordam Çağrısı - Arıza

Server replies: An error occurred while attempting to contact the server. Please check your network connection and try again.

Ben kundakçı açık ve http://localhost/sample1/sample1/greet için 404 dönüyor. Bu ben şaşırıp nerede .. Bu dosya Açıkçası benim webserver yok .. ama neden? GWT tarafından derlenen almak gerekiyordu bu şey değil mi?

Herkes bana bir el verebilir? Teşekkürler!

2 Cevap

Yani, temelde bir istemci / sunucu uygulaması istemci tarafında üzerinden kopyalanan ettik. GWT istemci uygulaması ilk örnek bir parçasıdır tebrik hizmet sunucuya bir Uzaktan Yordam Çağrısı (RPC) yapmak için çalıştığında, bu hizmeti bulamıyorum.

Eğer üzerinde bu hizmeti kopyalamak istedim, (daha fazla detay kontrol etmek olurdu), GreetingService üzerine ve belki birkaç diğer şeyler başvurduğu web.xml kopyalamak, bir Java uygulama sunucusu olması gerekiyordu. Yani aslında ne istediklerini gibi gelmiyor, bu yüzden ya o URL yanıt PHP GWT-RPC hizmetini kurmak isteyeceksiniz, ya da tebrik hizmet RPC çağrısı için GWT kodu başvurusunu kaldırın.

PHP arka uç ile, muhtemelen ben JSON veya XML kullanmak daha olasıdır olduğunuzu tahmin ediyorum, GWT-RPC kullanmak için gitmiyorsun, ve bu durum buysa, o zaman ben RPC kaldırılması ile gitmek istiyorum Şimdilik tamamen diyoruz.

Bu bütün mantıklı mı? Daha fazla açıklama istemek için çekinmeyin.

SOP sorunu çözmek için, ben geliştirme sunucusu aracılığıyla benim webserver için HttpProxyServlet proxy HTTP istekleri kullanılır.

İndir httpProxyPackage.jar, WEB-INF/lib/ içine kopyalayın ve böylece web kök içeren klasör olduğunu varsayarak, WEB-INF/web.xml (bu StockWatcher öğretici içindir gibi yapılandırabilirsiniz StockWatcher dizini):

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

: O olarak JSON URL yeniden tanımlamak

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

yerine:

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

Bu belki en iyi yol değil, ama bir başkası başladı alabilirsiniz eğer var ... php-cgi kullanarak başka bir yoluydu, ama yüklü yoktu.