Hi Nanadana:

My source code in client side:

        ConfigurationContext ctx =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("build/client_repositories",
null);

        ServiceClient client = new ServiceClient(ctx, null);
        Options options = new Options();
        options.setAction("urn:echo");
        options.setTo(new EndpointReference("
http://localhost:8081/axis2/services/RampartPolicy01";));
        options.setProperty(RampartMessageData.KEY_RAMPART_POLICY
,  loadPolicy("build/client_repositories/conf/policy.xml"));
        client.setOptions(options);

        client.engageModule("rampart");

        OperationClient opClient = client.createClient(
ServiceClient.ANON_OUT_IN_OP);

       XMLStreamReader xmlStreamReader = xmlItem.getXMLStreamReader();

       //xmlItem has the xml:
       //<soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/";>
       //<soapenv:Body>
       //<ns1:echo xmlns:ns1="http://policy.samples.gmv.org";>
       //<ns1:arg>aaaa</ns1:arg>
       // </ns1:echo>
        //</soapenv:Body>
       //</soapenv:Envelope>

       StAXBuilder builder = new StAXSOAPModelBuilder(xmlStreamReader,null);
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();

        client.addHeadersToEnvelope(env);

        MessageContext mc = new MessageContext();
        mc.setEnvelope(env);
        mc.setConfigurationContext(ctx);

        opClient.addMessageContext(mc);
        opClient.execute(true);

The service.xml is:

<service>
<operation name="echo">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
<parameter name="ServiceClass" locked="false">
org.gmv.samples.policy.SimpleService</parameter>

<module ref="rampart" />

<wsp:Policy wsu:Id="UTOverTransport" xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy";>
<wsp:ExactlyOne>
  <wsp:All>
<sp:TransportBinding xmlns:sp="
http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
  <wsp:Policy>
<sp:TransportToken>
  <wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
  </wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
  <wsp:Policy>
<sp:Basic256/>
  </wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
  <wsp:Policy>
<sp:Lax/>
  </wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp/>
  </wsp:Policy>
</sp:TransportBinding>
<sp:SignedSupportingTokens xmlns:sp="
http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="
http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient";
/>
  </wsp:Policy>
</sp:SignedSupportingTokens>

<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy";>
<ramp:user>alice</ramp:user>
<ramp:passwordCallbackClass>org.gmv.samples.policy.PWCBHandler
</ramp:passwordCallbackClass>
</ramp:RampartConfig>

  </wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</service>

The exception is:

Exception in thread "main" org.apache.axis2.AxisFault: SOAP header missing
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java
:486)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(
OutInAxisOperation.java:343)
at org.apache.axis2.description.OutInAxisOperationClient.send(
OutInAxisOperation.java:389)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(
OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.gmv.samples.policy.Client.main(Client.java:100)


Thanks,
Nuria

2008/3/26, Nandana Mihindukulasooriya <[EMAIL PROTECTED]>:
> Hi Nuria,
>        The important thing is whether operation is correctly
> dispatched when the security handlers are called. So can you give more
> information about how you configure the services and the client.
>
> thanks,
> /nandana
>
> On Tue, Mar 25, 2008 at 5:33 PM, Nuria Rodríguez García
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'd need to use policy with rampart module without using addressing
module.
> > Is it possible?
> >
> > I tested it and it works when I use sendReceive but when I execute an
> > operation client doesn't work.
> >
> > Thanks,
> > Nuria
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



2008/3/26, Nandana Mihindukulasooriya <[EMAIL PROTECTED]>:
> Hi Nuria,
>        The important thing is whether operation is correctly
> dispatched when the security handlers are called. So can you give more
> information about how you configure the services and the client.
>
> thanks,
> /nandana
>
> On Tue, Mar 25, 2008 at 5:33 PM, Nuria Rodríguez García
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'd need to use policy with rampart module without using addressing
module.
> > Is it possible?
> >
> > I tested it and it works when I use sendReceive but when I execute an
> > operation client doesn't work.
> >
> > Thanks,
> > Nuria
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to