Merhaba,
Asagidaki adrese XML gonderip ardindanda cevap olarak bir data almak
istiyorum
Kullanici adi ve password bilgileri dogruladigi icin code 200 reponse
aliyorum ama ardindan datayi alamiyorum bana yardimci olurmusunuz
Client tarafindan server tarafina gidiyorum
server dan diger servera baglaniyorum ancak data alamadim
kod asagida
package com.google.gwt.sample.stockwatcher.server;
package com.google.gwt.sample.stockwatcher.server;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HTTPProxy extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
protected void doPost( HttpServletRequest req, HttpServletResponse
res)
throws ServletException, IOException {
URL url=null;
String method = "GET",post = null;
int timeout = 0;
Set entrySet = req.getParameterMap().entrySet();
Map headers = new HashMap();
for( Iterator iter = entrySet.iterator(); iter.hasNext(); ){
Map.Entry header = (Map.Entry) iter.next();
String key = (String)header.getKey();
String value = ((String[])header.getValue())[0] ;
if( key.equals("method") )
method = value;
else if( key.equals("post") )
post = value;
else if( key.equals("url") )
url = new URL("http://www.hotelspro.com/xf_test_3.0/
hp_xml_request_parser.php?xml=");
else
headers.put( key, value );
}
//use a loop for handling redirects
boolean complete = false;
while( !complete ){
//set up the remote connection
HttpURLConnection urlConnection =
(HttpURLConnection)url.openConnection();
//urlConnection.setRequestProperty("AffiliateCodeValue", "xxx");
//urlConnection.setRequestProperty("AffiliateUsernameValue",
"xxx");
//urlConnection.setRequestProperty("AffiliatePasswordValue",
"xxx");
//urlConnection.setRequestProperty("AffRequestIdValue",
"1023456789");
//urlConnection.setRequestProperty("AffRequestTimeValue",
"2008-12-31T15:30:00");
//urlConnection.setRequestProperty("CompleteListValue",
"true");
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setInstanceFollowRedirects(false);
urlConnection.setRequestMethod(method);
if( timeout > 0 ) urlConnection.setConnectTimeout(timeout);
//copy the headers to the new connection
Set headersSet = headers.entrySet();
for( Iterator iter=headersSet.iterator(); iter.hasNext(); ){
Map.Entry header = (Map.Entry)iter.next();
urlConnection.setRequestProperty(
(String)header.getKey(),(String)header.getValue() );
}
//write post body to remote connection
if( post != null){
OutputStreamWriter outRemote = new
OutputStreamWriter(urlConnection.getOutputStream());
outRemote.write( post );
outRemote.flush();
}
//transfer contentType from remote connection
String contentType = urlConnection.getContentType();
if( contentType != null ) res.setContentType(contentType);
//check for a redirect
int responseCode = urlConnection.getResponseCode();
if( responseCode == 302 ){
String location = urlConnection.getHeaderField("Location");
url = new URL( location );
}
else{
//read from the appropriate stream
res.setStatus( responseCode );
BufferedInputStream in;
if( responseCode == 200 || responseCode == 201 ) // I GOT CODE
200 EVERY TIME BUT THATS IT NO RESPONSE I GOT WHAT SHOULD I DO
{
in = new
BufferedInputStream(urlConnection.getInputStream());}
else
in = new
BufferedInputStream(urlConnection.getErrorStream());
//send output to client
BufferedOutputStream out =
new BufferedOutputStream(res.getOutputStream());
int c;
while((c = in.read()) >= 0 )
out.write(c);
out.flush();
complete = true;
} } } }
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment