Hi all,
I'm still unable to solve the "Unable to engage module : rampart"
problem. Basically, I downloaded the lasted rampart-SNAPSHOT.mar module.
However, when I try to call the policy based service with my client, I
get the following exception:
Exception in thread "main" org.apache.axis2.AxisFault: Unable to engage
module : rampart
at
org.apache.axis2.client.ServiceClient.engageModule(ServiceClient.java:33
9)
at
org.apache.rampart.policy.CommandLineClient.main(CommandLineClient.java:
64)
However, everything works perfectly with rampart-1.3.mar so it appears
the service itself is fine.
I've also tried putting my axis2.xml as a parameter to the
ConfigurationContext object as suggested by Joana Trindade and as
described in [1] but no luck either. Is there anything else I need to
configure to get it working? Any pointers will be really helpful. I've
also added the client used to invoke the service below. Cheers.
[1] -
http://mail-archives.apache.org/mod_mbox/ws-rampart-dev/200802.mbox/%3c9
[EMAIL PROTECTED]
Regards
Sanjay
public class CommandLineClient {
private static EndpointReference targetEPR =
new EndpointReference(
"http://localhost:8080/axis2/services/PolicyEchoService");
private static String confPath = "C:\\rampart\\policy";
private static String axisPath =
"C:\\axis2-1.3\\conf\\axis2.xml";
public static void main(String[] args) throws Exception {
ConfigurationContext ctx =
ConfigurationContextFactory.
createConfigurationContextFromFileSystem(confPath,
axisPath);
ServiceClient client = new ServiceClient(ctx, null);
Options options = new Options();
options.setAction("urn:echo");
options.setTo(targetEPR);
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy( confPath + "/conf/policy.xml"));
//this username is authenticated against the PWHandlerClient
class
options.setUserName("sanjay");
client.setOptions(options);
client.engageModule("addressing");
client.engageModule("rampart");
OMElement result = client.sendReceive(getPayload());
String response = result.getFirstElement().getText();
System.out.println(response);
}
private static Policy loadPolicy(String xmlPath) throws Exception {
StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
private static OMElement getPayload() {
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns =
factory.createOMNamespace("http://policy.rampart.apache.org","ns1");
OMElement elem = factory.createOMElement("echo", ns);
return elem;
}
}