Hi,

there's two problems with this. First, you can't control followRedirects
from XFire, and second (worse), HttpClient does not support redirects for
POST and GET according to 
<http://jakarta.apache.org/httpcomponents/httpclient-3.x/redirects.html>

We also ran into this problem and solved it by creating the HttpClient instance
used by XFire ourselves. The idea is to override the executeMethod() in
order to handle redirects.


Starting from the example code you posted, you could try the following:
(see below)

Tomek Sztelak wrote:
Looks like you have to enable redirects on  httpclient (i guess its
disabled by default)

On 10/24/07, George.Francis <[EMAIL PROTECTED]> wrote:

[...]
        public static void main(String[] args) throws Throwable
        {
                XFire xfire = XFireFactory.newInstance().getXFire();
                XFireProxyFactory factory = new XFireProxyFactory(xfire);

                Service serviceModel = new
ObjectServiceFactory().create(ISMService.class);
                ISMService service = (ISMService) factory.create(serviceModel,
"http://rad223:8080/services/ISMService";);
                XFireProxy proxy =  
(XFireProxy)Proxy.getInvocationHandler(service);
                Client client = proxy.getClient();
                client.addOutHandler(new WSClient.ClientAuthHandler());
                client.setTransport(new SoapHttpTransport());


// extract the HttpClient instance from your XFire client
                
Channel channel = client.getOutChannel();
if (channel instanceof HttpChannel) {
        HttpChannel httpChannel=(HttpChannel)channel;
        final HttpClient oldClient=HttpUtils.createClient(httpChannel.getUri());

        HttpClient fixedClient = new HttpClient(){
                
                //handle redirects
                @Override
                public int executeMethod(HostConfiguration hostConfig, 
HttpMethod method, HttpState httpState) throws IOException, HttpException {
                int i=old.executeMethod(hostConfig, method, httpState);
                String redirectLocation;
                Header locationHeader = method.getResponseHeader("location");
                if (locationHeader != null) {
                        redirectLocation = locationHeader.getValue();           
                
                        method.setURI(new 
org.apache.commons.httpclient.URI(redirectLocation,false));
                        return executeMethod(hostConfig, method, httpState);
                } else {
                        // no redirect needed
                }
                return i;
                }
        };
        //set XFire to use the fixed client...
        httpChannel.setProperty(CommonsHttpMessageSender.HTTP_CLIENT, 
fixedClient);
}



                Method method = ISMService.class.getDeclaredMethods()[0];
                Object response = proxy.invoke(proxy, method, new 
Object[]{-1L});
                System.out.println( response );
        }
}



--
Dr. Bernd Schuller                     |  mail:  [EMAIL PROTECTED]
                                       |  phone: +49 2461 61-8736 (fax: -6656)
Distributed Systems and Grid Computing |  personal blog:
Juelich Supercomputing Centre          |  http://www.jroller.com/page/gridhaus
http://www.fz-juelich.de/jsc           |


-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
Forschungszentrum Jülich GmbH
52425 Jülich

Sitz der Gesellschaft: Jülich
Eingetragen im Handelsregister des Amtsgerichts Düren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDirig'in Bärbel Brumme-Bothe
Geschäftsführung: Prof. Dr. Achim Bachem (Vorsitzender), Dr. Ulrich Krafft (stellv. Vorsitzender)
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to