I kind of agree with Glen only you don't have to switch to wsdl you could
use @Policy annotations they work very well especially with 2.7.4 where we
did some additional fixes to clean it up.

It really depends what you want to do. For my project java first was a must
as we generate web services from a domain model and easier to generate the
java.

For username password policy stuff there are quite a few examples in
systests and other places but I agree with Glen more examples of other
policy stuff for wsdl first.

I would like to see more folks using java first with ws policy though as
cxf does work well

Happy to assist as I have just spent last 6 months on this stuff migrating
to ws policy from the wss4j interceptors
 On Mar 13, 2013 4:37 AM, "Glen Mazza" <[email protected]> wrote:

> Adam, I think you made the unfortunate decision of starting with
> code-first, calculating that it would be 20% simpler than WSDL-first, but
> because virtually no examples handle security from a Java-first perspective
> you're having several headaches downstream.  There goes your 20% (and then
> some). :(
>
> I'd recommend switching to WSDL-first[1] so you'll have the benefit of
> lots of examples to leverage for your own work.  You most likely wouldn't
> be using the antiquated WSS4JOutInterceptor if you were doing WSDL-first,
> instead you can just rely on WS-SecurityPolicy statements in your WSDL
> instead.  But, in the interim, hopefully someone else can provide you an
> answer for your question below.
>
> Glen
>
> [1] 
> http://www.jroller.com/gmazza/**entry/web_service_tutorial<http://www.jroller.com/gmazza/entry/web_service_tutorial>
>
> On 03/11/2013 11:16 PM, adamcchang wrote:
>
>> Thank you guys for the help.  However I am having this issue when I tried
>> to
>> add WSS4JOutInterceptor to my WS client.  I followed the example in
>> Mazza's
>> blog.
>>
>> Exception in thread "main" java.lang.ClassCastException:
>> com.sun.xml.internal.ws.**client.sei.SEIStub cannot be cast to
>> org.apache.cxf.frontend.**ClientProxy
>>
>>
>>         Map ctx = ((BindingProvider)**uciRoleServiceSOAP).**
>> getRequestContext();
>>         ctx.put("ws-security.username"**, "joe");
>>         ctx.put("ws-security.callback-**handler",
>> ClientPasswordCallback.class.**getName());
>>         // instead of above line can also do:
>>         // ctx.put("ws-security.password"**, "joespassword");
>>
>>
>>      // Alternative CXF interceptor config method
>>         org.apache.cxf.endpoint.Client client =
>> org.apache.cxf.frontend.**ClientProxy.getClient(**uciRoleServiceSOAP);
>>  <====
>> this is where the error happens
>>      org.apache.cxf.endpoint.**Endpoint cxfEndpoint =
>> client.getEndpoint();
>>      Map outProps = new HashMap();
>>      outProps.put(**WSHandlerConstants.ACTION,
>> WSHandlerConstants.USERNAME_**TOKEN);
>>      outProps.put(**WSHandlerConstants.USER, "joe");
>>      outProps.put(**WSHandlerConstants.PASSWORD_**TYPE,
>> WSConstants.PW_TEXT);
>>      outProps.put(**WSHandlerConstants.PW_**CALLBACK_CLASS,
>> ClientPasswordCallback.class.**getName());
>>      WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
>>      cxfEndpoint.**getOutInterceptors().add(**wssOut);
>>
>>
>> I have my client code (UciRoleServiceSOAP_Service
>> uciRoleServiceSOAP_Service
>> ) generated by wsdl2java.  Could anybody help me on how to get the
>> cxfclient
>> from a wsdl2java code please?  Thanks a lot.
>>
>> Regards,
>>
>> ~Adam
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://cxf.547215.n5.nabble.**
>> com/Interceptors-for-WS-**security-tp5722285p5724423.**html<http://cxf.547215.n5.nabble.com/Interceptors-for-WS-security-tp5722285p5724423.html>
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>
>

Reply via email to