[ http://jira.codehaus.org/browse/XFIRE-347?page=comments#action_63604 ] 

Bernd Schuller commented on XFIRE-347:
--------------------------------------

Hi Dan,

sure, I'd love to help on this.

I've attached a slightly changed org.codehaus.xfire.client.Client.java (based 
on the version 1.1 beta1) that copies the Addressing headers and factory from 
the service "model" specified by the user into the current message. Then the 
user can add his wsa headers to the service like this:

        Service serviceModel=factory.create(ResourceLifetime.class, "service", 
null, null);
        
serviceModel.setProperty(AddressingInHandler.ADRESSING_HEADERS.toString(),ah);
        
serviceModel.setProperty(AddressingInHandler.ADRESSING_FACTORY.toString(),new 
AddressingHeadersFactory200508());
        MyService s=(MyService)new XFireProxyFactory().create(serviceModel, 
url);
                
Provided the wsa AddressingOutHandler is active, this works as advertised. 

A further suggestion: it could be good to copy all headers, not just the 
addressing ones, but for this the AbstractContext class would need a method 
getProperties()

Best regards,
Bernd


> Use WS-Addressing with XFireProxy client
> ----------------------------------------
>
>          Key: XFIRE-347
>          URL: http://jira.codehaus.org/browse/XFIRE-347
>      Project: XFire
>         Type: Improvement

>   Components: Core
>     Versions: 1.1-beta-1
>  Environment: Java 5 on Linux
>     Reporter: Bernd Schuller
>     Assignee: Dan Diephouse
>      Fix For: 1.1
>  Attachments: Client.java
>
>
> When using the XFireProxy client to access a WS-Addressing enabled service, I 
> found it impossible to add headers such as wsa:To using the procedures 
> outlined in the user's guide. This is due to the fact that the user cannot 
> set any additional headers to be inserted.
> A possible workaround/solution looks as follows.
> 1. Define a new out Handler 
> public class MyAddressingOutHandler extends AddressingOutHandler {
>       Map properties;
>       
>       public MyAddressingOutHandler(Map properties){
>               this.properties=properties;
>       }
>       
>        public void invoke(MessageContext context) throws Exception{
>               AddressingHeaders headers = (AddressingHeaders) 
> properties.get(AddressingInHandler.ADRESSING_HEADERS);
>         AddressingHeadersFactory factory = (AddressingHeadersFactory) 
> properties.get(AddressingInHandler.ADRESSING_FACTORY);
>         
> context.getCurrentMessage().setProperty(AddressingInHandler.ADRESSING_HEADERS,headers);
>         
> context.getCurrentMessage().setProperty(AddressingInHandler.ADRESSING_FACTORY,factory);
>               super.invoke(context);
>       }       
> }
> 2. add the new handler to the xfire outhandlers
> 3. set the properties before invoking the proxy:
>                         Map properties=new HashMap();
>                       AddressingHeaders ah=new AddressingHeaders();
>                       ah.setAction("....");
>                       ah.setTo("......");
>                       
> properties.put(AddressingInHandler.ADRESSING_HEADERS.toString(),ah);
>                       
> properties.put(AddressingInHandler.ADRESSING_FACTORY.toString(),new 
> AddressingHeadersFactory200508());                  
>                       DefaultXFire 
> xfire=(DefaultXFire)XFireFactory.newInstance().getXFire();
>                       xfire.addOutHandler(new 
> MyAddressingOutHandler(properties));
>                       
> A real solution could be to copy the properties from the Service used to 
> create the proxy into the message context created in Client.invoke(), then 
> the standard wsa out handler would pick them up.
> sorry for the long rant :) 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to