Redirection interne d'une requete http

Fermé
kncwiller Messages postés 2 Date d'inscription lundi 13 octobre 2014 Statut Membre Dernière intervention 13 octobre 2014 - 13 oct. 2014 à 11:45
KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 - 13 oct. 2014 à 18:46
Salut,
actuellement je travaille sur une application web avec google app engine pour java.
j'ai expose un service qui reçoit des requetes Http Get via l'objet HttpServletRequest et doit retourner une reponse XML. le truc c'est que avant de retourner la reponse je dois faire une redirection interne vers un controleur spring pour effectuer un traitement.
ci-dessous mon code mais j'ai toujours une exception IOException.

httpInternalClient=new DefaultHttpClient();
		//String uri="http://www.abyster.com/MobileMoney/transfert.do";
		String uri="http://www.abyster.com/MobileMoney/transfert.do";
		HttpPost httpPost=new HttpPost(uri);
		List<NameValuePair> postParameters=new ArrayList<NameValuePair>();
		postParameters.add(new BasicNameValuePair("ab_amount",(String)entity.getProperty("amount")));
		postParameters.add(new BasicNameValuePair("ab_amountTTC",(String) entity.getProperty("amount")));
		postParameters.add(new BasicNameValuePair("ab_commission",(String) entity.getProperty("charges")));
		postParameters.add(new BasicNameValuePair("ab_countryCode", (String)entity.getProperty("countrycode")));
		postParameters.add(new BasicNameValuePair("ab_currency",(String) entity.getProperty("currency")));
		postParameters.add(new BasicNameValuePair("ab_fee", (String)entity.getProperty("charges")));
		postParameters.add(new BasicNameValuePair("ab_msisdnReceiver",(String) entity.getProperty("receiver")));
		postParameters.add(new BasicNameValuePair("ab_msisdnSender",(String) entity.getProperty("sender")));
		postParameters.add(new BasicNameValuePair("ab_operatorNewMMBalance",(String) entity.getProperty("balance")));
		postParameters.add(new BasicNameValuePair("ab_operatorTransactionId",(String) entity.getProperty("trxID")));
		
		try {
			httpPost.setEntity(new UrlEncodedFormEntity(postParameters));
			httpPost.setHeader("Content-Type","application/x-www-form-urlencoded");
			HttpResponse response= httpInternalClient.execute(httpPost);
			dService.delete(key);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


N.B: je n'ai pas accès à l'object HttpServletResponse depuis ma methode.

je ne sais pas si quelqu'un a une idée de comment m'y prendre.
merçi d'avance pour vos réponses.

2 réponses

KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
13 oct. 2014 à 13:36
Bonjour,

Pourquoi être reparti aussi bas niveau que HttpServletRequest pour exposer ton service XML ? Tu aurais pu faire du JAX-WS ou JAX-RS c'est quand même fait pour...

Sinon, c'est quoi l'erreur que tu as ?
0
kncwiller Messages postés 2 Date d'inscription lundi 13 octobre 2014 Statut Membre Dernière intervention 13 octobre 2014
13 oct. 2014 à 13:55
Slt KX,
en fait voici l'erreur que j'ai

org.apache.http.impl.client.DefaultRequestDirector tryConnect: I/O exception (java.net.SocketException) caught when connecting to the target host: Permission denied: Attempt to access a blocked recipient without permission. (mapped-IPv4)

il fat noter que mon application est hebergé sur la plateforme Google App Engine
0
KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
13 oct. 2014 à 18:46
Cette erreur c'est Google qui te la renvoie car tu ne respectes pas les limitations du cloud (tu ne peux pas faire ce que tu veux)

https://cloud.google.com/appengine/docs/standard/java/sockets
0