You could write a handler to do it:
public class HeaderHandler extends AbstractHandler {
public void invoke(MessageContext context) {
context.getOutMessage().getHeader().addContent(new Element(....));
}
}
Client client = ((XFireProxy) Proxy.getInvocationHandler(service));
client.addOutHandler(new HeaderHandler());
An easier way though might be to use JSR 181 and the
@WebParam.header=true. Then you can declare headers in your service
interface:
public void doSomething(@WebParam(header=true) AuthToken token, String
parm1, String param2);
- Dan
[EMAIL PROTECTED] wrote:
Hello there,
im new to XFire and SOAP WebServices. But because of the ease usage of the
XFire API i have already some web-services up and running.
Environment description:
Running on Tomcat 5.5.12
Services wired and exported using String-XFireExporter
Now it's time to think about some security issues in my system. I want to
have those security issues handled by myself and so
i thought about writing an InHandler for some of the services. The
handler-side is really clear after reading the online tutorial on
http://xfire.codehaus.org/Writing+Handlers and
http://xfire.codehaus.org/Authentication. I decided to use the 'Soap Header
Authentication with Handlers'
as described by the tutorial.
Now it comes to the clients. I have no idea how to pass (using the XFire
Client API) such headers to the web-service.
The client code lookes something like this
Service serviceModel = new ObjectServiceFactory().create(MyService.class);
MyService service = (MyService)new XFireProxyFactory().create(serviceModel,
"http://localhost:8081/app/services/MyService");
service.doSomething( param1, param2 );
Can anybody give me a hint how to pass the required soap headers as shown
by the tutorial example
<AuthenticationToken xmlns="urn:yourapp:authentication">
<Username>test</Username>
<Password>123</Password>
</AuthenticationToken>
on service invocation level ?
Thanx for your help
Sebastian Wiemer
_________________________
Diese E-Mail (ggf. nebst Anhang) enthält vertrauliche und/oder rechtlich
geschützte Informationen. Wenn Sie nicht der richtige Adressat sind, oder
diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die
unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail (and any attachment/s) contains confidential and/or privileged
information. If you are not the intended recipient (or have received this
e-mail in error) please notify the sender immediately and destroy this
e-mail. Any unauthorised copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
_________________________
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com
http://netzooid.com/blog