• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirect requested but followRedirects is disabled INFO HTTPSender Unable to sendViaPost to url[

 
praneeth gajji
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,Thanks to all in advance
I am unable to consume external web service through Axis2 from resource http://www.webservicex.net/CurrencyConvertor.asmx
Please help me to solve the issue,I am getting this exception in production environment,it is working fine in my development environment

Please help me how to get out of this problem how can I enable redirects do I need to to any axis2 configuration changes or else can it be done from code.
Stack Trace I am getting
----------------------------------
10:36:22,751 INFO [HttpMethodDirector] Redirect requested but followRedirects is disabled
10:36:22,751 INFO [HTTPSender] Unable to sendViaPost to url[http://www.webservicex.net/CurrencyConvertor.asmx]
org.apache.axis2.AxisFault: Transport error: 302 Error: Moved Temporarily
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:296)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:190)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:371)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:209)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at com.gsscrmservice.curconv.CurrencyConvertorStub.ConversionRate(CurrencyConvertorStub.java:322)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.gesmallworld.gss.lib.service.Axis2WebService.handleRequest(Axis2WebService.java:279)
at com.gsscrmservice.curconvEJB.CurrencyConvertorBean.ConversionRate(CurrencyConvertorBean.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.gesmallworld.gss.lib.service.Service.makeRequest(Service.java:489)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegati


I have given below code inorder for proxy configuration in dev but same is not working in prod Please help.

HttpTransportProperties.ProxyProperties pp = new HttpTransportProperties.ProxyProperties();
pp.setProxyName("172.16.108.174");
pp.setProxyPort(8080);

pp.setUserName(prop.getProperty("userName"));
pp.setPassWord(prop.getProperty("password"));
_serviceClient.getOptions().setProperty(HTTPConstants.PROXY,pp);

HttpTransportProperties.Authenticator auth =new HttpTransportProperties.Authenticator();

auth.setUsername(prop.getProperty("userName"));
auth.setPassword(prop.getProperty("password"));
auth.setPreemptiveAuthentication(true);
auth.setRealm(HttpTransportProperties.Authenticator.BASIC);
List authPrefs = new Vector<String>(1);
authPrefs.add(AuthPolicy.BASIC);
_serviceClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE,auth);

_serviceClient.getOptions().setProperty(AuthPolicy.AUTH_SCHEME_PRIORITY,authPrefs);
// _serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);

THANKS IN ADVANCE to all.
 
praneeth gajji
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

My problem got solved , I have added following peace of code for my stub inorder to solve the issue, I have provided the domain information also to my proxy settings

Properties prop = new Properties();

try {
String jbossPath="";
Map<String,String> env = System.getenv();
for(String envTemp:env.keySet()){
if(envTemp.equalsIgnoreCase("JBOSS_HOME")){
//System.out.println("Key:"+envTemp+"--Value:"+env.get(envTemp));
jbossPath = env.get(envTemp);
break;
}
}
jbossPath = jbossPath + "\\server\\default\\conf\\application_files";
//load a properties file
prop.load(new FileInputStream(jbossPath +"\\TATA_POWER.properties"));

//get the property value and print it out
System.out.println("USERNAME++++++++++++++++++"+prop.getProperty("userName"));
System.out.println("PWD+++++++++++++++"+prop.getProperty("password"));

} catch (IOException ex) {
ex.printStackTrace();
}
//******************************************************
HttpTransportProperties.ProxyProperties pp = new HttpTransportProperties.ProxyProperties();
pp.setProxyName(prop.getProperty("portName"));
pp.setProxyPort(Integer.parseInt(prop.getProperty("port")));
pp.setDomain(prop.getProperty("domain"));
pp.setUserName(prop.getProperty("userName"));
pp.setPassWord(prop.getProperty("password"));


HttpTransportProperties.Authenticator auth =new HttpTransportProperties.Authenticator();

auth.setUsername(prop.getProperty("userName"));
auth.setPassword(prop.getProperty("password"));
auth.setPreemptiveAuthentication(true);
auth.setRealm(HttpTransportProperties.Authenticator.BASIC);
// auth.setRealm("GSS Auth");
List authPrefs = new Vector<String>(1);
authPrefs.add(AuthPolicy.BASIC);

_serviceClient.getOptions().setProperty(HTTPConstants.PROXY,pp);
_serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);
org.apache.commons.httpclient.HttpMethod get = new GetMethod("http://www.webservicex.net/CurrencyConvertor.asmx");
get.setFollowRedirects(true);
_serviceClient.getOptions().setProperty(HTTPConstants.AUTHENTICATE,auth);

_serviceClient.getOptions().setProperty(AuthPolicy.AUTH_SCHEME_PRIORITY,authPrefs);
_serviceClient.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);

get.setDoAuthentication(true);
System.out.println("get.getFollowRedirects()*************"+get.getFollowRedirects());
return _serviceClient;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic