1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public static void main(String[] args) {
Service serviceModel = new AnnotationServiceFactory().create(HelloImpl.class);
try {
Hello service = (Hello)new XFireProxyFactory().create(serviceModel,"http://localhost:8080/webservicestest/services/HelloService");
Client client = Client.getInstance(service);
client.addOutHandler(new DOMOutHandler());
Properties outProperties = new Properties();
configureOutProperties(outProperties);
client.addOutHandler(new WSS4JOutHandler(outProperties));
String s = service.world2();
System.out.println(s);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
protected static void configureOutProperties(Properties config)
{
config.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
config.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
config.setProperty(WSHandlerConstants.USER, "user");
config.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, PasswordHandler.class.getName());
} |
Partager