Hello:I have the sample code:
----------------------------------------------------------------------
// creating the SOAPEnvelope from a XML file
FileReader soapFileReader = new
FileReader("C:\\RaviWS\\axis2ws\\XML\\WSS_SAMPLE_03.xml");
            XMLStreamReader parser =

 XMLInputFactory.newInstance().createXMLStreamReader(soapFileReader);
            StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser,
null);
            SOAPEnvelope envelope = (SOAPEnvelope)
builder.getDocumentElement();



 System.out.println(" input SOAPMessage is \n " + envelope );

            //Blocking invocation
            ServiceClient client = new ServiceClient();
            OperationClient opClient =
client.createClient(ServiceClient.ANON_OUT_IN_OP);

            // creating outMsgContext
            MessageContext outMsgCxt = new MessageContext();

            // creating Options and setting it to the MessageContext
            Options options = outMsgCxt.getOptions();
            options.setTo(targetEPR);
            options.setAction("urn:echo");

            // creating the username token
            options.setProperty(WSHandlerConstants.USER, "bob");
            options.setProperty(WSHandlerConstants.PASSWORD_TYPE,
WSConstants.PASSWORD_TEXT);

 
options.setProperty(WSHandlerConstants.USERNAME_TOKEN,UserNameToken.getWSUNameToken());
            options.setProperty(WSHandlerConstants.MUST_UNDERSTAND,"true");


            //adding the envelope to the outMsgCxt
            outMsgCxt.setEnvelope(envelope);

            // adding the MsgContext to the opClient
            opClient.addMessageContext(outMsgCxt);

---------------------------------------------------------------------------------------------
When I call execute on opClient and monitor the message, could see that the
security headers are not added.

Could you please give me pointers on how I should proceed further. I have to
do everything dynamic.

May be I need to engage the rampart modules etc.

Any help is greatly appreciated.

Thanks,
cabear

On Wed, Jan 28, 2009 at 2:21 PM, Wishing Carebear <
[email protected]> wrote:

> Thanks Sameera.I have downloaded the rampart and understanding the
> samples. Interestingly in the basic one, there is a mention of
> DynamicConfiguration as item 11 but do not see any relevant examples.
>
> Anyway will try out to have a better understand and get back to you if I
> have more questions.
>
> Best regards,
> cabear
>
>
> On Wed, Jan 28, 2009 at 11:31 AM, Sameera Jayasoma <
> [email protected]> wrote:
>
>>
>>
>> On Tue, Jan 27, 2009 at 1:55 AM, Wishing Carebear <
>> [email protected]> wrote:
>>
>>> Sameera:
>>> Looked into 240 link. It had the following information for client
>>> configurations:
>>> This configuration parameter should be included in the client's axis2.xml
>>> file and in sample-02 the file is
>>> "rampart-ut-samples/sample02/client.axis2.xml".
>>>
>>> My requirement is to do the WS-Security programmatically. Is it possible
>>> using rampart and axis2.
>>
>>
>> Yes, this should be possible. If you are using  WS-SecurityPolicy to
>> indicate the security actions, anyway you need to specify that policy.xml
>> file. Please have a look at the Apache Rampart site for more details..
>>
>> Following shows, how you should secure SOAP message using Rampart with
>> WS-SecurityPolicy. Rampart policy sample02
>>
>> public static void main(String[] args) throws Exception {
>>
>>         if(args.length != 3) {
>>             System.out.println("Usage: $java Client endpoint_address
>> client_repo_path policy_xml_path");
>>         }
>>
>>         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("addressing");
>>         client.engageModule("rampart");
>>
>>         OMElement response = client.sendReceive(getPayload("Hello
>> world"));
>>
>>         System.out.println(response);
>>
>>     }
>>
>>
>>
>>
>>
>>>
>>> Thanks for your time and help,
>>> cbear
>>>
>>> On Sun, Jan 25, 2009 at 6:32 AM, Sameera Jayasoma <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> You can achieve WS-Security with Apache Axis2 by using Rampart. Rampart
>>>> is an Axis2 module. For more information please refer following articles.
>>>>
>>>> http://wso2.org/library/3190
>>>> http://wso2.org/library/240
>>>>
>>>>
>>>>
>>>> On Sat, Jan 24, 2009 at 8:15 AM, Wishing Carebear <
>>>> [email protected]> wrote:
>>>>
>>>>> Hello:
>>>>> I'm using the Cleint API's (ServiceClient and OperationClient) to
>>>>> consume webservices. I have been successful so far writing dynamic 
>>>>> clients (
>>>>> without using wsdl2java).
>>>>>
>>>>> Now want to integrate WSSecurity feature with the dynamic clients.
>>>>>
>>>>> Would like to know if there are any examples how to do WS_Security with
>>>>> Axis2.
>>>>>
>>>>> Thanks for your time and help
>>>>> cabear
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sameera Jayasoma
>>>> Software Engineer
>>>> WSO2 Inc.
>>>> Oxygenating the Web Service Platform.
>>>> http://wso2.org/
>>>>
>>>> blog: http://tech.jayasoma.org
>>>>
>>>
>>>
>>
>>
>> --
>> Sameera Jayasoma
>> Software Engineer
>> WSO2 Inc.
>> Oxygenating the Web Service Platform.
>> http://wso2.org/
>>
>> blog: http://tech.jayasoma.org
>>
>
>

Reply via email to