Since i do not want to create a lot of wsit fi开发者_如何学运维les to enable security (encryption of message and authentication of users) and i do not want to use netbeans to use the metro plugin there, i want to ask if there is any easy way to implement ws-security via annotations? Or is there any eclipse plugin besides soap ui, which is in fact not very usefull, to create such wsit files?
Thanks in advance.
According to this post, Metro does not support ws-policy programmatically. That was 2009 though, so I don't know if that's still the case.
Metro can get the policy directly from the WSDL too if you don't want to use wsit files (if you have the policy in the WSDL at all, that is).
This is how I did in my Metro-generated service class. It loads the policy directly from the WSDL, which is in my classpath, and will apply all policies in runtime, provided that you have installed Metro in your application server and don't have any conflicting dependencies in your project (this one was a bit of a hassle for me to find, some of my dependencies had jaxws-rt
as a dependency, which may ruin Metros policy resolving).
private final static URL CUSTOMERSERVICE_WSDL_LOCATION;
static {
CUSTOMERSERVICE_WSDL_LOCATION =
CustomerService.class.getClassLoader().getResource("Customer/CustomerService.wsdl");
}
public CustomerService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
精彩评论