[jboss-user] [JBossWS] - Using WSSecurityHandlerOutbound in a DII client
acxjbertr
do-not-reply at jboss.com
Mon Jul 31 16:34:22 EDT 2006
I've got a DII client coded up and everything works as expected. However, now I am trying to test my WS-Security setup. My JBoss server (4.0.4 with JBossWS 1.0.2) requires WS-Security signatures on all incoming SOAP messages. It accurately denies my invocations if I don't sign my messages, but now I want to make it accept my messages. I have read elsewhere that I need to configure a handler to sign my outgoing messages. I have tried to do this in the code below:
package com.mycompany.client.test.ws;
|
| import ...
|
| public class WSTestCase extends TestCase {
| private String testDescription = null;
|
| // Possible Outputs
| private String exceptionThrown = null;
|
| public void testPlanStep1() throws MalformedURLException, ServiceException {
| go(getInput());
| }
|
| private void go(Echo request) throws ServiceException, MalformedURLException {
| try {
| ClientStuffEndpoint clientStuffEndpoint = getEndpoint();
| EchoResponse echoResponse = clientStuffEndpoint.echo(request);
|
| ClientStuffReply clientStuffReply = echoResponse.getResult();
| System.out.println(clientStuffReply.getAuditId());
| } catch (Exception e) {
| e.printStackTrace();
| assertTrue(false);
| }
| }
|
| private ClientStuffEndpoint getEndpoint() throws MalformedURLException, ServiceException, InvalidRequestException, SystemUnavailableException, RemoteException {
| ServiceFactoryImpl factory = new ServiceFactoryImpl();
| ClassLoader cl = Thread.currentThread().getContextClassLoader();
| URL wsdlLocation = cl.getResource("wsdl/ClientStuff.wsdl");
| URL mappingLocation = cl.getResource("client-mapping.xml");
| QName serviceName = new QName("http://client.mycompany.com/clientstuff/1.0", "ClientStuff");
| ServiceImpl service = (ServiceImpl) factory.createService(wsdlLocation, serviceName, mappingLocation);
| setupHandlerRegistry(service);
| return (ClientStuffEndpoint) service.getPort(ClientStuffEndpoint.class);
| }
|
| private Echo getInput() {
| Echo echoInput = new Echo();
| ClientStuffRequest clientStuffRequest = new ClientStuffRequest();
| clientStuffRequest.setAuditId("eggie");
| echoInput.setClientStuffRequest_1(clientStuffRequest);
|
| return echoInput;
| }
|
| private void setupHandlerRegistry(ServiceExt service) {
| List<HandlerInfo> clientHandlerChain = new ArrayList<HandlerInfo>();
| HandlerInfo handler = new HandlerInfo();
| handler.setHandlerClass(WSSecurityHandlerOutbound.class);
| clientHandlerChain.add(handler);
| QName securityName = new QName(org.jboss.ws.wsse.WSS_SOAP_NS, "ClientStuffEndpointPort");
| service.getDynamicHandlerRegistry().setHandlerChain(securityName, clientHandlerChain);
| }
| }
|
Unfortunately my messages still aren't being signed.
I was unsure about what to put on the line QName securityName = new QName(org.jboss.ws.wsse.WSS_SOAP_NS, "ClientStuffEndpointPort"); and I think this might be the cause of the problem. Can anyone advise me of the correct values here? I have tried several different values from the org.jboss.ws.wsse package.
Any help would be greatly appreciated. Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962009#3962009
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962009
More information about the jboss-user
mailing list