Adding the following should do

List assertionList = (List) alternatives.next();
XmlPrimtiveAssertion xmlPrim = (XmlPrimtiveAssertion) assertionList.get(0);
System.out.println(xmlPrim.getValue());

Best,
Sanka

On 8/9/07, Ami Desai <[EMAIL PROTECTED]> wrote:
>
>
>   Hello Sir,
>
>   Thanking you very much  for your help.
>
>   I tried your code. I got following output
>
>   [EMAIL PROTECTED]
>
>   Again I cannot get a string output of @1787038.
>   Can I get a string output of @1787038?
>   For comparing requirment I require string output.
>   Is there any other way to do so?
>
>   Thanks
>
>   With Regards
>   Amee Desai
>
>
> Sanka Samaranayake <[EMAIL PROTECTED]> wrote:
>   Hi Ami,
>
> Following sinppet demonstrate the proper way to access an assertion in a
> policy.
>
> policy.getAlternatives() will return a iterator from which you can get a
> list of assertions of an alternative.
>
> Since your policy contains only one alternative it iterator will return
> only
> one list. ( in othe words you can call iterator.next() only once). That
> list will contain only a single assertion which you wanted to have access.
>
> sample code:
>
> String targetPolicy =
> "http://schemas.xmlsoap.org/ws/2004/09/policy\"; xmlns:sp=\"
> http://schemas.xmlsoap.org/ws/2005/07/securitypolicy\";>" +
> " " +
> "" +
> "" +
> "" +
> "" +
> "";
>
> ByteArrayInputStream bais = new ByteArrayInputStream(
> targetPolicy.getBytes());
> Policy policy = PolicyEngine.getPolicy(bais);
>
> Iterator alternatives = policy.getAlternatives();
> List assertionList = (List) alternatives.next();
> System.out.println(assertionList.get(0));
>
> HTH
>
> Best,
> Sanka
>
> On 8/9/07, Ami Desai wrote:
> >
> > Respected Sir,
> >
> > I have queries related to WS-Policy. I am using Apache Neethi-2.0.1 for
> > implementing WS-Policy. I write my policy file in xml. Now i wnat to get
> > assertion from that file. For that I am using getAssertions() method of
> All
> > class.
> > My java code is
> >
> >
> ---------------------------------------------------------------------------
> > PolicyEngine pe1=new PolicyEngine();
> > List l1,l2;
> > Object o2=new Object();
> > FileInputStream fis = new FileInputStream("C:\\neethi-
> > 2.0.1-bin\\policyex12.xml");
> > l2=(pe1.getPolicy(fis)).getAssertions();
> > o2=l2.get(0);
> > System.out.println(o2);
> >
> >
> -------------------------------------------------------------------------
> > My policy file is
> >
> >
> -------------------------------------------------------------------------
> > > xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy";>
> >
> >
> >
> >
> >
> --------------------------------------------------------------------------
> > And I get output as
> > [EMAIL PROTECTED]
> >
> > I think i cannot get exact assertion. I think @b09e89 is my assertion
> > and beause it is contained in Object, When I ty to convert them into
> string
> > I get garbage value. So For getting assertion into string what should I
> have
> > to do?
> >
> > Is my approach right or wrong? Is there any other mehtod available for
> > doing same thing?
> >
> > Please slove this queries.
> >
> > Thanks
> >
> > With Regards,
> > Amee Desai
> >
> >
> >
> > ---------------------------------
> > 5, 50, 500, 5000 - Store unlimited mails in your inbox. Click here.
>
>
>
>
> --
> Sanka Samaranayake
> WSO2 Inc.
>
> http://www.bloglines.com/blog/sanka
> http://www.wso2.org/
>
>
>
> ---------------------------------
> Once upon a time there was 1 GB storage in your inbox. Click here for
> happy ending.




-- 
Sanka Samaranayake
WSO2 Inc.

http://www.bloglines.com/blog/sanka
http://www.wso2.org/

Reply via email to