Don't connect to the server... it's a project in last gwt eclipse
on click to button in gwt:
greetServer(textToServer,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel
.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
my gwt server:
public String greetServer(String input) throws IllegalArgumentException {
// Verify that the input is valid.
if (!FieldVerifier.isValidName(input)) {
// If the input is not valid, throw an IllegalArgumentException back to
// the client.
throw new IllegalArgumentException(
"Name must be at least 4 characters long");
}
String serverInfo = getServletContext().getServerInfo();
String userAgent = getThreadLocalRequest().getHeader("User-Agent");
// Escape data from the client to avoid cross-site script vulnerabilities.
input = escapeHtml(input);
userAgent = escapeHtml(userAgent);
return "Hello, " + input + "!<br><br>I am running " + serverInfo
+ ".<br><br>It looks like you are using:<br>" + userAgent;
}
it's my gwt servise:
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}
gwt serviseAsyn file:
public interface GreetingServiceAsync {
void greetServer(String input, AsyncCallback<String> callback)
throws IllegalArgumentException;
}
web xml
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>kill.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/hello123/greet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Hello123.html</welcome-file>
</welcome-file-list>
on click button - the server does not return value, because don't find file - why?
Jun 27, 2012 11:12:13 AM com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /com.mycompany.project.ImageViewer/GreetingService
what to do?
In your web.xml
file you map the service as /hello123/greet
:
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/hello123/greet</url-pattern>
</servlet-mapping>
while the error shows it is trying to load the default of /modulename/serviceinterfacename
, or /com.mycompany.project.ImageViewer/GreetingService
. Two options are available:
web.xml
entry to use the default url that the RPC interface expectsBoth of theses are discussed briefly at https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication, along with other RPC setup details.
For the second option, this usually looks like this:
MyServiceAsync service = GWT.create(MyService.class);
((ServiceDefTarget)service).setServiceEntryPoint("/hello123/greet");
service.methodName(...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With