Return-Path: Delivered-To: apmail-ws-axis-user-archive@www.apache.org Received: (qmail 3907 invoked from network); 3 Mar 2005 18:47:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 3 Mar 2005 18:47:09 -0000 Received: (qmail 19476 invoked by uid 500); 3 Mar 2005 18:47:02 -0000 Delivered-To: apmail-ws-axis-user-archive@ws.apache.org Received: (qmail 19026 invoked by uid 500); 3 Mar 2005 18:47:01 -0000 Mailing-List: contact axis-user-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-user@ws.apache.org list-help: list-unsubscribe: List-Post: Delivered-To: mailing list axis-user@ws.apache.org Received: (qmail 19012 invoked by uid 99); 3 Mar 2005 18:47:00 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of davanum@gmail.com designates 64.233.170.192 as permitted sender) Received: from rproxy.gmail.com (HELO rproxy.gmail.com) (64.233.170.192) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 03 Mar 2005 10:47:00 -0800 Received: by rproxy.gmail.com with SMTP id 34so337633rns for ; Thu, 03 Mar 2005 10:46:58 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=OMqD4QjqN/X7m8vRXEA48vzntfLKyaiFDBku4FZ2prILPzHDyrcy79hr5Wtu5/uCsONc4BkvT0IQvdJNmZbhusM0d87mdb9vpKSCb5pDC+q68AXcyXKxoIOect9+NyHzsXp6rkLiEl5kjbYJXrZav2RJBuUPN4wwobkdSGn1/Lc= Received: by 10.38.206.49 with SMTP id d49mr44036rng; Thu, 03 Mar 2005 10:46:58 -0800 (PST) Received: by 10.38.8.79 with HTTP; Thu, 3 Mar 2005 10:46:58 -0800 (PST) Message-ID: <19e0530f050303104653bd4b73@mail.gmail.com> Date: Thu, 3 Mar 2005 13:46:58 -0500 From: Davanum Srinivas Reply-To: dims@apache.org To: axis-user@ws.apache.org Subject: Re: Server redirected too many times with Axis and Java 1.5 In-Reply-To: <42275B33.5000800@praud.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable References: <42275B33.5000800@praud.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 wr= ote: > Hi all, >=20 > 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 : >=20 > java.net.ProtocolException: Server redirected too many times (20) > AxisFault > faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userExcepti= on > faultSubcode: > faultString: java.net.ProtocolException: Server redirected too many > times (20) faultActor: > faultNode: > faultDetail: >=20 > {http://xml.apache.org/axis/}stackTrace:java.net.ProtocolException: > Server redirected too many times (20) >=20 > (snip stacktrace) >=20 > I tried to upgrade to Axis 1.2RC3, re-fetch MapPoint WSDL and recompile > the MapPoint classes with JDK 1.5... >=20 > The SOAP query uses a custom HTTP authenticator (see attached file). The > exception is thrown by the statement conn.getContentType() : >=20 > private void readFromConnection(URLConnection conn, MessageContext > messageContext) > throws Exception { > String contentType =3D conn.getContentType(); >=20 > What did I miss ? >=20 > Thanks, >=20 > JC >=20 > Full Stack Trace follows : >=20 > java.net.ProtocolException: Server redirected too many times (20) > AxisFault > faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userExcepti= on > faultSubcode: > faultString: java.net.ProtocolException: Server redirected too many > times (20) faultActor: > faultNode: > faultDetail: >=20 > {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(NativeConstructorAc= cessorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConst= ructorAccessorImpl.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(HttpURLCo= nnection.java:1180) > at > sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnect= ion.java:877) > at > sdt.SimpleHTTPSender.readFromConnection(SimpleHTTPSender.java:100) > at sdt.SimpleHTTPSender.invoke(SimpleHTTPSender.java:61) > at > org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.ja= va: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(FindServiceSoa= pStub.java:1259) > at > sdt.LocationInformation.findAddressHelper(LocationInformation.java:123) > at sdt.LocationInformation.findAddress(LocationInformation.java:6= 6) > 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:21= 69) > at > javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.jav= a:420) > at > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) > at > javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListe= ner.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.j= ava:163) > at > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.j= ava: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:21= 69) > at > javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.jav= a:420) > at > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) > at > javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListe= ner.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.j= ava: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(HttpURLConnect= ion.java:1141) > at > sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnect= ion.java:1850) > at java.net.URLConnection.getContentType(URLConnection.java:479) > at sdt.SimpleHTTPSender.readFromConnection(SimpleHTTPSender.java:= 95) > ... 67 more >=20 > {http://xml.apache.org/axis/}hostname:yogsothoth >=20 > 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.ja= va: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(FindServiceSoa= pStub.java:1259) > at > sdt.LocationInformation.findAddressHelper(LocationInformation.java:123) > at sdt.LocationInformation.findAddress(LocationInformation.java:6= 6) > 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:21= 69) > at > javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.jav= a:420) > at > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) > at > javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListe= ner.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.j= ava:163) > at > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.j= ava: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:21= 69) > at > javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.jav= a:420) > at > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) > at > javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListe= ner.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.j= ava: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(NativeConstructorAc= cessorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConst= ructorAccessorImpl.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(HttpURLCo= nnection.java:1180) > at > sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnect= ion.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(HttpURLConnect= ion.java:1141) > at > sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnect= ion.java:1850) > at java.net.URLConnection.getContentType(URLConnection.java:479) > at sdt.SimpleHTTPSender.readFromConnection(SimpleHTTPSender.java:= 95) > ... 67 more >=20 > -- > Jean-Christophe Praud - http://shub-niggurath.com > Conseil & D=E9veloppement Informatique http://www.praud.com > Ph'nglui mglw'nafh Cthulhu n'gah Bill R'lyeh Wgah'nagl fhtagn! >=20 >=20 > package sdt; >=20 > import java.io.*; > import java.net.*; > import org.apache.axis.*; > import org.apache.axis.handlers.*; >=20 > /** > * SimpleHTTPSender is an HTTP transport handler for the Axis library, pr= oviding > * basic HTTP communication with the server. This class is needed in ord= er 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 prov= ide a file > * named "client-config.wsdd" in a directory on the classpath, containing= these lines: > * > * > * * xmlns=3D"http://xml.apache.org/axis/wsdd/" > * xmlns:java=3D"http://xml.apache.org/axis/wsdd/providers/java= "> > * > * > * > */ > public class SimpleHTTPSender extends BasicHandler { >=20 > /** > * SimpleAuthenticator provides the user name and password to an URLCon= nection. > */ > private static class SimpleAuthenticator extends Authenticator { > private PasswordAuthentication m_authentication; >=20 > SimpleAuthenticator(String userName, String password) { > m_authentication =3D new PasswordAuthentication(userName, password.= toCharArray()); > } >=20 > protected PasswordAuthentication getPasswordAuthentication() { > return m_authentication; > } > } >=20 > /** > * Invoke a remote call using an URLConnection. This method is called = by Axis. > */ > public void invoke(MessageContext messageContext) > throws AxisFault { > try { > String userName =3D messageContext.getUsername(); > String password =3D messageContext.getPassword(); > if (userName !=3D null && password !=3D null) { > Authenticator.setDefault(new SimpleAuthenticator(userName, passwo= rd)); > } >=20 > System.out.println("HTTP QUERY: "+messageContext.getStrProp(Message= Context.TRANS_URL)); > URL url =3D new URL(messageContext.getStrProp(MessageContext.TRANS_= URL)); > URLConnection conn =3D url.openConnection(); > writeToConnection(conn, messageContext); > readFromConnection(conn, messageContext); > } > catch (Exception e) { > throw AxisFault.makeFault(e); > } > finally { > Authenticator.setDefault(null); > } > } >=20 > /** > * Write the SOAP request message to an URLConnection. > */ > private void writeToConnection(URLConnection conn, MessageContext messa= geContext) > throws Exception { > conn.setDoOutput(true); > Message request =3D messageContext.getRequestMessage(); > String contentType =3D request.getContentType(messageContext.getSOAPC= onstants()); > conn.setRequestProperty("Content-Type", contentType); > if (messageContext.useSOAPAction()) { > conn.setRequestProperty("SOAPAction", messageContext.getSOAPActionU= RI()); > } > OutputStream out =3D new BufferedOutputStream(conn.getOutputStream(),= 8192); > request.writeTo(out); > out.flush(); > } >=20 > /** > * Read the SOAP response message from an URLConnection. > */ > private void readFromConnection(URLConnection conn, MessageContext mess= ageContext) > throws Exception { > String contentType =3D conn.getContentType(); > String contentLocation =3D conn.getHeaderField("Content-Location"); >=20 > InputStream in =3D ((HttpURLConnection) conn).getErrorStream(); > if (in =3D=3D null) { > in =3D conn.getInputStream(); > } > in =3D new BufferedInputStream(in, 8192); > Message response =3D new Message(in, false, contentType, contentLocat= ion); > response.setMessageType(Message.RESPONSE); > messageContext.setResponseMessage(response); > } > } >=20 >=20 >=20 --=20 Davanum Srinivas - http://webservices.apache.org/~dims/