axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <dava...@gmail.com>
Subject Re: Server redirected too many times with Axis and Java 1.5
Date Thu, 03 Mar 2005 18:46:58 GMT
Don't use the custom thingy. use CommonsHTTPSender that is already in axis.

-- dims


On Thu, 03 Mar 2005 19:45:07 +0100, Jean-Christophe Praud <jc@praud.com> wrote:
> Hi all,
> 
> I'm trying to use the MapPoint WebService using Axis as a client. All
> worked fine with JDK 1.4. But with JDK 1.5, I get this error :
> 
> java.net.ProtocolException: Server redirected too many  times (20)
> AxisFault
>  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
>  faultSubcode:
>  faultString: java.net.ProtocolException: Server redirected too many
> times (20) faultActor:
>  faultNode:
>  faultDetail:
> 
> {http://xml.apache.org/axis/}stackTrace:java.net.ProtocolException:
> Server redirected too many  times (20)
> 
> (snip stacktrace)
> 
> I tried to upgrade to Axis 1.2RC3, re-fetch MapPoint WSDL and recompile
> the MapPoint classes with JDK 1.5...
> 
> The SOAP query uses a custom HTTP authenticator (see attached file). The
> exception is thrown by the statement conn.getContentType() :
> 
>   private void readFromConnection(URLConnection conn, MessageContext
> messageContext)
>   throws Exception {
>     String contentType = conn.getContentType();
> 
> What did I miss ?
> 
> Thanks,
> 
> JC
> 
> Full Stack Trace follows :
> 
> java.net.ProtocolException: Server redirected too many  times (20)
> AxisFault
>  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
>  faultSubcode:
>  faultString: java.net.ProtocolException: Server redirected too many
> times (20) faultActor:
>  faultNode:
>  faultDetail:
> 
> {http://xml.apache.org/axis/}stackTrace:java.net.ProtocolException:
> Server redirected too many  times (20)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)        at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>         at
> sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1186)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1180)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:877)
>         at
> sdt.SimpleHTTPSender.readFromConnection(SimpleHTTPSender.java:100)
>         at sdt.SimpleHTTPSender.invoke(SimpleHTTPSender.java:61)
>         at
> org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
>         at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
>         at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
>         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
>         at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
>         at org.apache.axis.client.Call.invoke(Call.java:2737)
>         at org.apache.axis.client.Call.invoke(Call.java:2413)
>         at org.apache.axis.client.Call.invoke(Call.java:2336)
>         at org.apache.axis.client.Call.invoke(Call.java:1793)
>         at
> net.mappoint.s.mappoint_30.FindServiceSoapStub.findAddress(FindServiceSoapStub.java:1259)
>         at
> sdt.LocationInformation.findAddressHelper(LocationInformation.java:123)
>         at sdt.LocationInformation.findAddress(LocationInformation.java:66)
>         at sdt.SalesClientXY.geocode(SalesClientXY.java:90)
>         at sdt.SalesClientXY.access$0(SalesClientXY.java:77)
>         at sdt.SalesClientXY$1.actionPerformed(SalesClientXY.java:286)
>         at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
>         at
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
>         at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
>         at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
>         at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
>         at java.awt.Component.processMouseEvent(Component.java:5488)
>         at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
>         at java.awt.Component.processEvent(Component.java:5253)
>         at java.awt.Container.processEvent(Container.java:1966)
>         at java.awt.Component.dispatchEventImpl(Component.java:3955)
>         at java.awt.Container.dispatchEventImpl(Container.java:2024)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
>         at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
>         at java.awt.Container.dispatchEventImpl(Container.java:2010)
>         at java.awt.Window.dispatchEventImpl(Window.java:1766)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
>         at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
>         at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
>         at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
>         at java.awt.Dialog$1.run(Dialog.java:515)
>         at java.awt.Dialog.show(Dialog.java:536)
>         at sdt.SaleClientEdit.openXY(SaleClientEdit.java:810)
>         at sdt.SaleClientEdit.access$11(SaleClientEdit.java:806)
>         at sdt.SaleClientEdit$43.actionPerformed(SaleClientEdit.java:2429)
>         at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
>         at
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
>         at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
>         at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
>         at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
>         at java.awt.Component.processMouseEvent(Component.java:5488)
>         at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
>         at java.awt.Component.processEvent(Component.java:5253)
>         at java.awt.Container.processEvent(Container.java:1966)
>         at java.awt.Component.dispatchEventImpl(Component.java:3955)
>         at java.awt.Container.dispatchEventImpl(Container.java:2024)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
>         at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
>         at java.awt.Container.dispatchEventImpl(Container.java:2010)
>         at java.awt.Window.dispatchEventImpl(Window.java:1766)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
>         at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
>         at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
>         at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
> Caused by: java.net.ProtocolException: Server redirected too many  times
> (20)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1141)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:1850)
>         at java.net.URLConnection.getContentType(URLConnection.java:479)
>         at sdt.SimpleHTTPSender.readFromConnection(SimpleHTTPSender.java:95)
>         ... 67 more
> 
>         {http://xml.apache.org/axis/}hostname:yogsothoth
> 
> java.net.ProtocolException: Server redirected too many  times (20)
>         at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
>         at sdt.SimpleHTTPSender.invoke(SimpleHTTPSender.java:64)
>         at
> org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
>         at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
>         at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
>         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
>         at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
>         at org.apache.axis.client.Call.invoke(Call.java:2737)
>         at org.apache.axis.client.Call.invoke(Call.java:2413)
>         at org.apache.axis.client.Call.invoke(Call.java:2336)
>         at org.apache.axis.client.Call.invoke(Call.java:1793)
>         at
> net.mappoint.s.mappoint_30.FindServiceSoapStub.findAddress(FindServiceSoapStub.java:1259)
>         at
> sdt.LocationInformation.findAddressHelper(LocationInformation.java:123)
>         at sdt.LocationInformation.findAddress(LocationInformation.java:66)
>         at sdt.SalesClientXY.geocode(SalesClientXY.java:90)
>         at sdt.SalesClientXY.access$0(SalesClientXY.java:77)
>         at sdt.SalesClientXY$1.actionPerformed(SalesClientXY.java:286)
>         at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
>         at
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
>         at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
>         at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
>         at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
>         at java.awt.Component.processMouseEvent(Component.java:5488)
>         at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
>         at java.awt.Component.processEvent(Component.java:5253)
>         at java.awt.Container.processEvent(Container.java:1966)
>         at java.awt.Component.dispatchEventImpl(Component.java:3955)
>         at java.awt.Container.dispatchEventImpl(Container.java:2024)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
>         at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
>         at java.awt.Container.dispatchEventImpl(Container.java:2010)
>         at java.awt.Window.dispatchEventImpl(Window.java:1766)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
>         at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
>         at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
>         at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
>         at java.awt.Dialog$1.run(Dialog.java:515)
>         at java.awt.Dialog.show(Dialog.java:536)
>         at sdt.SaleClientEdit.openXY(SaleClientEdit.java:810)
>         at sdt.SaleClientEdit.access$11(SaleClientEdit.java:806)
>         at sdt.SaleClientEdit$43.actionPerformed(SaleClientEdit.java:2429)
>         at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
>         at
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
>         at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
>         at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
>         at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
>         at java.awt.Component.processMouseEvent(Component.java:5488)
>         at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
>         at java.awt.Component.processEvent(Component.java:5253)
>         at java.awt.Container.processEvent(Container.java:1966)
>         at java.awt.Component.dispatchEventImpl(Component.java:3955)
>         at java.awt.Container.dispatchEventImpl(Container.java:2024)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
>         at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
>         at java.awt.Container.dispatchEventImpl(Container.java:2010)
>         at java.awt.Window.dispatchEventImpl(Window.java:1766)
>         at java.awt.Component.dispatchEvent(Component.java:3803)
>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
>         at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
>         at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
>         at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
> Caused by: java.net.ProtocolException: Server redirected too many  times
> (20)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)        at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>         at
> sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1186)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1180)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:877)
>         at
> sdt.SimpleHTTPSender.readFromConnection(SimpleHTTPSender.java:100)
>         at sdt.SimpleHTTPSender.invoke(SimpleHTTPSender.java:61)
>         ... 66 more
> Caused by: java.net.ProtocolException: Server redirected too many  times
> (20)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1141)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:1850)
>         at java.net.URLConnection.getContentType(URLConnection.java:479)
>         at sdt.SimpleHTTPSender.readFromConnection(SimpleHTTPSender.java:95)
>         ... 67 more
> 
> --
> Jean-Christophe Praud         -      http://shub-niggurath.com
> Conseil & Développement Informatique      http://www.praud.com
> Ph'nglui mglw'nafh Cthulhu n'gah Bill R'lyeh Wgah'nagl fhtagn!
> 
> 
> package sdt;
> 
> import java.io.*;
> import java.net.*;
> import org.apache.axis.*;
> import org.apache.axis.handlers.*;
> 
> /**
>  * SimpleHTTPSender is an HTTP transport handler for the Axis library, providing
>  * basic HTTP communication with the server.  This class is needed in order to use
>  * MapPoint .NET, because Axis does not yet support digest authentication.  The
>  * CommonsHTTPSender almost works, but it currently fails with large POST requests,
>  * such as those that are sent when calling GetRouteMap with a very long route.
>  * These problems might be fixed in the future, eliminating the need for this class.
>  *
>  * You must configure Axis to use this class.  The easiest way is to provide a file
>  * named "client-config.wsdd" in a directory on the classpath, containing these lines:
>  *
>  *   <?xml version="1.0" encoding="UTF-8"?>
>  *   <deployment name="defaultClientConfig"
>  *           xmlns="http://xml.apache.org/axis/wsdd/"
>  *           xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
>  *     <transport name="http" pivot="java:SimpleHTTPSender"/>
>  *     <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/>
>  *   </deployment>
>  */
> public class SimpleHTTPSender extends BasicHandler {
> 
>   /**
>    * SimpleAuthenticator provides the user name and password to an URLConnection.
>    */
>   private static class SimpleAuthenticator extends Authenticator {
>     private PasswordAuthentication m_authentication;
> 
>     SimpleAuthenticator(String userName, String password) {
>       m_authentication = new PasswordAuthentication(userName, password.toCharArray());
>     }
> 
>     protected PasswordAuthentication getPasswordAuthentication() {
>       return m_authentication;
>     }
>   }
> 
>   /**
>    * Invoke a remote call using an URLConnection.  This method is called by Axis.
>    */
>   public void invoke(MessageContext messageContext)
>   throws AxisFault {
>     try {
>       String userName = messageContext.getUsername();
>       String password = messageContext.getPassword();
>       if (userName != null && password != null) {
>         Authenticator.setDefault(new SimpleAuthenticator(userName, password));
>       }
> 
>       System.out.println("HTTP QUERY: "+messageContext.getStrProp(MessageContext.TRANS_URL));
>       URL url = new URL(messageContext.getStrProp(MessageContext.TRANS_URL));
>       URLConnection conn = url.openConnection();
>       writeToConnection(conn, messageContext);
>       readFromConnection(conn, messageContext);
>     }
>     catch (Exception e) {
>       throw AxisFault.makeFault(e);
>     }
>     finally {
>       Authenticator.setDefault(null);
>     }
>   }
> 
>   /**
>    * Write the SOAP request message to an URLConnection.
>    */
>   private void writeToConnection(URLConnection conn, MessageContext messageContext)
>   throws Exception {
>     conn.setDoOutput(true);
>     Message request = messageContext.getRequestMessage();
>     String contentType = request.getContentType(messageContext.getSOAPConstants());
>     conn.setRequestProperty("Content-Type", contentType);
>     if (messageContext.useSOAPAction()) {
>       conn.setRequestProperty("SOAPAction", messageContext.getSOAPActionURI());
>     }
>     OutputStream out = new BufferedOutputStream(conn.getOutputStream(), 8192);
>     request.writeTo(out);
>     out.flush();
>   }
> 
>   /**
>    * Read the SOAP response message from an URLConnection.
>    */
>   private void readFromConnection(URLConnection conn, MessageContext messageContext)
>   throws Exception {
>     String contentType = conn.getContentType();
>     String contentLocation = conn.getHeaderField("Content-Location");
> 
>     InputStream in = ((HttpURLConnection) conn).getErrorStream();
>     if (in == null) {
>       in = conn.getInputStream();
>     }
>     in = new BufferedInputStream(in, 8192);
>     Message response = new Message(in, false, contentType, contentLocation);
>     response.setMessageType(Message.RESPONSE);
>     messageContext.setResponseMessage(response);
>   }
> }
> 
> 
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Mime
View raw message