Reputation: 98
I am learning GWT and trying to create a sample application. GWT version is 2.5.1. In the EntryPint
I have this code
HTTPRequest.asyncGet
(GWT.getHostPageBaseURL() + "person.xml",
new ResponseTextHandler() {
public void onCompletion(String responseText) {
// code goes here
}
}
I do have the import for HTTP
.
import com.google.gwt.user.client.HTTPRequest;
But this fails to import and the error looks like -
[javac] import com.google.gwt.user.client.HTTPRequest;
[javac] ^
[javac] symbol : variable HTTPRequest
[javac] location: class com.google.gwt.sample.client.TalkToServer
[javac] HTTPRequest.asyncGet
Also, I added this line in gwt.xml file
<inherits name='com.google.gwt.http.HTTP'/>
Am I missing something here ?
Upvotes: 0
Views: 248
Reputation: 64541
com.google.gwt.user.client.HTTPRequest
had been deprecated since GWT 1.5 (more than 5 years ago) and has been removed in GWT 2.1.0 (3 years ago).
Use com.google.gwt.http.client.RequestBuilder
instead.
Upvotes: 3
Reputation: 3832
To get the XML from the server, try something like this:
final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, “person.xml“);
builder.setCallback(new RequestCallback() {
@override
public void onError(final Request request, final throwable exception) {
// handle Exception
}
@override
public void onResponseRecieved(final Request request, final Response response) {
// handle Reponse - use response.getText() to get the response text
}
};
Use the GWT XML-Handling to parse your XML. You will find information here:
http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsXML.html
Hope that helps
Upvotes: 1