Hi,

I've developed a Web Service with UserName Token authentication (and password 
digest).

Then I've generated the stubs and I've build a simple client. When I launch my 
.jar it works fine!

However I must build a website as a WS client deployed on Tomcat. I've used the 
same code both time:
String target = "http://192.168.0.6:8081/axis2/services/WSInterface";;
WSInterfaceStub stub = new WSInterfaceStub(target);
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,loadPolicy("policy.xml"));
options.setUserName("alice");
options.setPassword("bob");
client.engageModule("rampart");

Here is loadPolicy():
   private static Policy loadPolicy(String xmlPath) throws Exception {
       StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
       return PolicyEngine.getPolicy(builder.getDocumentElement());
   }

So this code works on my simple client (.jar) but not for the servlet. I can 
build the .war file and then deploy it on Tomcat but when I go to 
http://localhost:8080/mysite/Index I got the following error:
java.io.FileNotFoundException: policy.xml (No such file or directory) 

I tried to put policy.xml inside the .war at different location but without 
success.

I wondering if someone here have already succeeded on creating a secure WS 
client with Tomcat.

Alternative: do you know another way to specify policy without XML file? I 
mean, without: 
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,loadPolicy("policy.xml"));

Regards,
Julien


      

Reply via email to