public Service createService(Class<?> clazz, Class<?> interfaze, String name) throws InvalidInterfaceException {
Service service = assemblyFactory.createService();
JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
service.setInterfaceContract(interfaceContract);
JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
if (name == null) {
String serviceName = interfaze.getSimpleName();
// If the interface has @WebService annotation then take the
// service name from the @name attribute if present
if (interfaze.isAnnotationPresent(WebService.class)){
if (callInterface.getQName() != null){
serviceName = callInterface.getQName().getLocalPart();
}
}
service.setName(serviceName);
} else {
service.setName(name);
}
boolean remotable = clazz.getAnnotation(Remotable.class) != null;
if (remotable){
callInterface.setRemotable(true);
}
service.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
if (remotable){
callbackInterface.setRemotable(true);
}
service.getInterfaceContract().setCallbackInterface(callbackInterface);
}
return service;
}