Add this to your handler.
public QName[] getUnderstoodHeaders() {
return new QName[] {
new QName("http://docs.oasis-open.org/wss/2004/01/" +
"oasis-200401-wss-wssecurity-secext-1.0.xsd",
"Security")
};
}
Here's the complete example:
http://arsenalist.com/2007/01/18/implementing-ws-security-with-jsr181-annotations-using-wss4j-in-xfire/
dave g wrote:
>
> hi,
>
> getting the same problem... has anyone got the answer to this one?
>
> thanks!
>
>
> Zarar Siddiqi wrote:
>>
>> I'm trying to implement ws-security using JSR181 annotations and wrote a
>> custom handler which contains all the other handlers, since handlers with
>> parameters cannot be used in annotations. The service is deployed fine
>> bu every time I try to invoke it, I get the following exception:
>>
>>
>> Exception in thread "main" org.codehaus.xfire.XFireRuntimeException:
>> Could not invoke service.. Nested exception is
>> org.codehaus.xfire.fault.XFireFault: Header
>> {Security}http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
>> was not undertsood by the service.
>> org.codehaus.xfire.fault.XFireFault: Header
>> {Security}http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
>> was not undertsood by the service.
>> at
>> org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
>> at
>> org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
>> at
>> org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
>> at
>> org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
>> at
>> org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
>> at org.codehaus.xfire.client.Client.onReceive(Client.java:382)
>> at
>> org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
>> at
>> org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
>> at
>> org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
>> at
>> org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
>> at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
>> at org.codehaus.xfire.client.Client.invoke(Client.java:335)
>> at
>> org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
>> ......
>>
>> I'm not sure what this means.
>>
>> Here's the Custom Handler class:
>>
>> public class WSSecurityHandler extends AbstractHandler {
>>
>> List<Handler> inHandlers;
>>
>> public WSSecurityHandler() {
>> WSS4JInHandler wss4jInHandler;
>> ValidateUserTokenHandler userTokenHandler;
>>
>> Properties props = new Properties();
>> props.put("action", "UsernameToken");
>> props.put("passwordCallbackClass",
>> PasswordHandler.class.getName());
>> wss4jInHandler = new WSS4JInHandler(props);
>> userTokenHandler = new ValidateUserTokenHandler();
>>
>> inHandlers = new ArrayList<Handler>();
>> inHandlers.add(wss4jInHandler);
>> inHandlers.add(userTokenHandler);
>> }
>> public void invoke(MessageContext messageContext) throws Exception {
>> for (Handler handler : inHandlers) {
>> handler.invoke(messageContext);
>> }
>> }
>> }
>>
>>
>> and here's how the service class is annotated:
>>
>> @WebService(endpointInterface = "my.package.PersonService")
>> @InHandlers(handlers={"my.package.WSSecurityHandler",
>> "org.codehaus.xfire.util.dom.DOMInHandler"})
>> public class PersonSoapService implements PersonService {
>>
>>
>> Here's the calling code:
>>
>> Properties properties = new Properties();
>> properties.setProperty(WSHandlerConstants.ACTION,
>> WSHandlerConstants.USERNAME_TOKEN);
>> properties.setProperty(WSHandlerConstants.PASSWORD_TYPE,
>> WSConstants.PW_DIGEST);
>> properties.setProperty(WSHandlerConstants.USER, "serveralias");
>> properties.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
>> PasswordHandler.class.getName());
>>
>> Service serviceModel = new
>> ObjectServiceFactory().create(PersonService.class, "PersonService",
>> "http://xfire.codehaus.org/PersonService", null);
>> PersonService service = (PersonService) new
>> XFireProxyFactory().create(serviceModel,
>> "http://localhost:8080/ws-core/services/PersonSoapService");
>> Client client = ((XFireProxy)
>> Proxy.getInvocationHandler(service)).getClient();
>> client.addOutHandler(new DOMOutHandler());
>> client.addOutHandler(new WSS4JOutHandler(properties));
>> service.doStuff();// invoke service
>>
>>
>> I'm following ws-security example in the XFire 1.2.4 distribution
>>
>> Any help is appreciated.
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/%22XSD-was-not-undertsood-by-the-service%22-when-using-JSR181-and-ws-security-tf3017986.html#a11099242
Sent from the XFire - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email