Hi,

You can include them in the client side policy using the RampartConfig
assertion.

More about these assertions can be found here[1]. Please take a look at
policy files of samples which are available in the Rampart binary
distribution.

Thanks,
Thilina

[1] - http://axis.apache.org/axis2/java/rampart/rampartconfig-guide.html


Thilina Mahesh Buddhika
http://blog.thilinamb.com


On Sat, Feb 5, 2011 at 3:35 AM, Devdatta Lele <lele.devda...@gmail.com>wrote:

> Hi,
>
> I am creating a simple client program in java to talk with the Server that
> has the WS security enabled. I am new to Axis2, Rampart.
>
> the developer who implemented the WS security on server gave me a wsdl file
> and told me that the he used the Rampart module for security.
>
> So first of all, I downloaded the wsdl file and downloaded Axis2 / Java ...
> then I used wsdl2java tool to create java classes from wsdl file.
>
> I also downloaded the Rampart module and then copied all the libs together
> (axis 2 and rampart libs) and added in the classpath of my client project in
> eclipse.
>
> Then he said follow 3 steps to start communicating with server:
>
> 1) Engage rampart module
> 2) load policy to set the property of the stub that gets created in
> wsdl2java classes
> 3) set the key in a property of the stub.
>
> So I created first of all a Configurationcontext pointing to the location
> where Rampart and Axis2 repositories are located.
>
> ConfigurationContext ctx =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:\\axis2-1.5.4\\repository",
> null);
>
> Then instantiated the stub
>
> ObjectWSStub ObjectStub = new ObjectWSStub(ctx, targetEndpoint);
>
> where targetEndpoint is the URL of the server where security is enabled.
>
> Then I am engaging the module:
>
> ObjectStub._getServiceClient().engageModule("rampart");
>
> And then setting the property for policy:
>
> ObjectStub._getServiceClient().getOptions().setProperty(RampartMessageData.KEY_RAMPART_POLICY,
> loadPolicy("policy.xml"))
>
>
> where loadPolicy is as follows and policy.xml is the piece of policy code
> that I separated out from the wsdl file that the developer provided.
>
> private static Policy loadPolicy(String name) throws Exception {
>
>         StAXOMBuilder builder = new StAXOMBuilder(name);
>         return PolicyEngine.getPolicy(builder.getDocumentElement());
>
>     }
>
>
>
>
> Now the question is where and how do I set the key ? I have the key .. its
> just that I dont know where and how to set.
>
> Please help.
>
> Thanks.
>

Reply via email to