Hi Jorge,
Try setting the corresponding policy at the client's end.
StAXOMBuilder builder = new StAXOMBuilder("path/to/policy");
Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement());
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, servicePolicy);
Thanks.
/thilina
Thilina Mahesh Buddhika
http://blog.thilinamb.com
On Sun, Mar 28, 2010 at 9:11 AM, Jorge Infante Osorio <[email protected]>wrote:
> Hi all. I need some help with a problem.
>
>
>
> I use Axis2 1.5.1, Rampart 1.4, and Eclipse and I´m trying to follow the
> tutorial in <http://wso2.org/library/3190> http://wso2.org/library/3190but
> I have an error:
>
>
>
> [INFO] Deploying module: rahas-1.4 -
>
> file:/D:/DesarrolloWS/IDE/ET/ETSeguridad/WebServiceProject/client-repo/modul
> es/rahas-1.4.mar
>
> [INFO] Deploying module: rampart-1.4 -
>
> file:/D:/DesarrolloWS/IDE/ET/ETSeguridad/WebServiceProject/client-repo/modul
> es/rampart-1.4.mar
>
> [INFO] Deploying module: metadataExchange-1.5.1 -
> file:/D:/DesarrolloWS/jars/mex-1.5.1.jar
>
> [ERROR] SOAP header missing
>
> org.apache.axis2.AxisFault: SOAP header missing
>
>
>
> this is my client:
>
>
>
> public static void main(String[] args) throws Exception {
>
>
>
> System.setProperty("javax.net.ssl.trustStore",
> "keys/server.jks");
>
> System.setProperty("javax.net.ssl.trustStorePassword",
> "password");
>
>
>
> //To be able to load the client configuration from axis2.xml
>
> ConfigurationContext ctx =
>
> ConfigurationContextFactory.createConfigurationContextFromFileSystem("client
> -repo", null);
>
>
>
> SecureServiceStub stub= new SecureServiceStub(ctx,"
> <https://localhost:8443/axis2/services/SecureService>
> https://localhost:8443/axis2/services/SecureService");
>
>
>
>
>
> ServiceClient sc = stub._getServiceClient();
>
>
>
> sc.engageModule("rampart");
>
>
>
> Options options = sc.getOptions();
>
> options.setUserName("apache");
>
> options.setPassword("password");
>
>
>
> int a = 3;
>
> int b = 4;
>
> Add param = new Add();
>
> param.setA(a);
>
> param.setB(b);
>
>
>
> AddResponse respuesta = new AddResponse();
>
> respuesta = stub.add(param);
>
>
>
> System.out.println(a + " + " + b + " = " +
> respuesta.get_return());
>
>
>
> }
>
>
>
> }
>
>
>
> The error occur in the line: respuesta= stub.add(param).
>
>
>
> I found that in the SecureServiceStub, specific in this part of code appear
> the error:
>
>
>
> // create SOAP envelope with that payload
>
> org.apache.axiom.soap.SOAPEnvelope env = null;
>
>
>
>
>
> env =
> toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
>
> add0,
>
> optimizeContent(new
> javax.xml.namespace.QName(" <http://service.rampart.tutorial>
> http://service.rampart.tutorial",
>
> "add")));
>
>
>
> //adding SOAP soap_headers
>
> _serviceClient.addHeadersToEnvelope(env);
>
> // set the message context with that soap envelope
>
> _messageContext.setEnvelope(env);
>
>
>
> // add the message contxt to the operation client
>
> _operationClient.addMessageContext(_messageContext);
>
>
>
> //execute the operation client
>
> _operationClient.execute(true);
>
> Any help???
>
>
>
> Jorge.
>
>
>
>