the Rampart group suggests constructing ServiceClient using the
ConfigurationContext as first parameter as seen here
ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(args[1],
null);
ServiceClient client = new ServiceClient(ctx, null);
Options options = new Options();
options.setAction("urn:echo");
options.setTo(new EndpointReference(args[0]));
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy(args[2]));
client.setOptions(options);
client.engageModule("rampart");
OMElement response = client.sendReceive(getPayload("Hello world"));
please ping rampart group for followup
http://ws.apache.org/rampart/mail-lists.html
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
Date: Thu, 1 Apr 2010 15:45:10 -0700
From: [email protected]
Subject: serviceClient sendRecieve call gives NullPointer - Axis2 client code
To: [email protected]
Axis2 client code gives nullpointerexception. Here is the client code:public
class SecureServiceCGClient { public static void main(String[] args) throws
Exception { ConfigurationContext ctx
=ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:\\IdeaProjects\\repo",null);
SecureServiceStub stub =
newSecureServiceStub(ctx,"https://localhost:8080/axis2/services/SecureService");
ServiceClient sc = stub._getServiceClient();
sc.engageModule("rampart"); Options options = new Options();
options.setAction("urn:add");
options.setTo(newEndpointReference("http://127.0.0.1:8080/axis2/services/SecureService"));
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy("C:\\apache-tomcat-6.0.24\\webapps\\axis2\\WEB-INF\\services\\SecureService\\META-INF\\policy.xml"));
sc.setOptions(options); /* Policy rampartConfig
=loadPolicy("C:\\apache-tomcat-6.0.24\\webapps\\axis2\\WEB-INF\\services\\SecureService\\META-INF\\policy.xml");
sc.getAxisService().getPolicyInclude().addPolicyElement(PolicyInclude.AXIS_SERVICE_POLICY,rampartConfig);
*/ String a = "3"; String b = "4"; OMElement
response = sc.sendReceive(getPayload(a, b));
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(String val, String val1) { OMFactory factory
= OMAbstractFactory.getOMFactory(); OMNamespace ns
=factory.createOMNamespace("http://secureservice.tutorial.rampart.apache.org","ns1");
OMElement method = factory.createOMElement("add", ns); OMElement
value1 = factory.createOMElement("value1", ns); value1.setText(val);
method.addChild(value1); OMElement value2 =
factory.createOMElement("value2", ns); value1.setText(val1);
method.addChild(value2); return method; } }The exception is
Exception in thread "main" java.lang.NullPointerException
atorg.apache.rampart.util.RampartUtil.setKeyIdentifierType(RampartUtil.java:1141)
atorg.apache.rampart.builder.BindingBuilder.getSignatureBuider(BindingBuilder.java:243)
atorg.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:626)
atorg.apache.rampart.builder.AsymmetricBindingBuilder.doSignBeforeEncrypt(AsymmetricBindingBuilder.java:413)
atorg.apache.rampart.builder.AsymmetricBindingBuilder.build(AsymmetricBindingBuilder.java:93)
at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:147) at
org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64) at
org.apache.axis2.engine.Phase.invoke(Phase.java:318) at
org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:251) at
org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:416)
atorg.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
atorg.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
atorg.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
atorg.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:540)
atorg.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:521)
attutorial.rampart.client.SecureServiceCGClient.main(SecureServiceCGClient.java:42)Disconnected
from the target VM, address: '127.0.0.1:3967', transport:'socket'Process
finished with exit code 1Any tips on resolving this will be
helpful.Thanks,Monisha
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/210850553/direct/01/