use of javax.xml.ws.WebServiceException in project teiid by teiid.
the class WSWSDLProcedureExecution method execute.
public void execute() throws TranslatorException {
List<Argument> arguments = this.procedure.getArguments();
XMLType docObject = (XMLType) arguments.get(0).getArgumentValue().getValue();
StAXSource source = null;
try {
source = convertToSource(docObject);
Dispatch<StAXSource> dispatch = conn.createDispatch(StAXSource.class, executionFactory.getDefaultServiceMode());
String operation = this.procedure.getProcedureName();
if (this.procedure.getMetadataObject() != null && this.procedure.getMetadataObject().getNameInSource() != null) {
operation = this.procedure.getMetadataObject().getNameInSource();
}
QName opQName = new QName(conn.getServiceQName().getNamespaceURI(), operation);
dispatch.getRequestContext().put(MessageContext.WSDL_OPERATION, opQName);
if (source == null) {
// JBoss Native DispatchImpl throws exception when the source is null
// $NON-NLS-1$
source = new StAXSource(XMLType.getXmlInputFactory().createXMLEventReader(new StringReader("<none/>")));
}
this.returnValue = dispatch.invoke(source);
} catch (SQLException e) {
throw new TranslatorException(e);
} catch (WebServiceException e) {
throw new TranslatorException(e);
} catch (XMLStreamException e) {
throw new TranslatorException(e);
} catch (IOException e) {
throw new TranslatorException(e);
} finally {
Util.closeSource(source);
}
}
use of javax.xml.ws.WebServiceException in project teiid by teiid.
the class WSConnectionImpl method createDispatch.
public <T> Dispatch<T> createDispatch(String binding, String endpoint, Class<T> type, Mode mode) {
ArgCheck.isNotNull(binding);
if (endpoint != null) {
try {
new URL(endpoint);
// valid url, just use the endpoint
} catch (MalformedURLException e) {
// otherwise it should be a relative value
// but we should still preserve the base path and query string
String defaultEndpoint = this.mcf.getEndPoint();
String defaultQueryString = null;
String defaultFragment = null;
if (defaultEndpoint == null) {
// $NON-NLS-1$
throw new WebServiceException(WSManagedConnectionFactory.UTIL.getString("null_default_endpoint"));
}
// $NON-NLS-1$
String[] parts = defaultEndpoint.split("\\?", 2);
defaultEndpoint = parts[0];
if (parts.length > 1) {
defaultQueryString = parts[1];
// $NON-NLS-1$
parts = defaultQueryString.split("#");
defaultQueryString = parts[0];
if (parts.length > 1) {
defaultFragment = parts[1];
}
}
if (endpoint.startsWith("?") || endpoint.startsWith("/") || defaultEndpoint.endsWith("/")) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
endpoint = defaultEndpoint + endpoint;
} else {
// $NON-NLS-1$
endpoint = defaultEndpoint + "/" + endpoint;
}
if ((defaultQueryString != null) && (defaultQueryString.trim().length() > 0)) {
endpoint = WSConnection.Util.appendQueryString(endpoint, defaultQueryString);
}
if ((defaultFragment != null) && (endpoint.indexOf('#') < 0)) {
endpoint = endpoint + '#' + defaultFragment;
}
}
} else {
endpoint = this.mcf.getEndPoint();
if (endpoint == null) {
// $NON-NLS-1$
throw new WebServiceException(WSManagedConnectionFactory.UTIL.getString("null_endpoint"));
}
}
Dispatch<T> dispatch = null;
if (HTTPBinding.HTTP_BINDING.equals(binding) && (type == DataSource.class)) {
Bus bus = BusFactory.getThreadDefaultBus();
BusFactory.setThreadDefaultBus(this.mcf.getBus());
try {
dispatch = (Dispatch<T>) new HttpDispatch(endpoint, this.mcf.getConfigFile(), this.mcf.getConfigName());
} finally {
BusFactory.setThreadDefaultBus(bus);
}
} else {
// TODO: cache service/port/dispatch instances?
Bus bus = BusFactory.getThreadDefaultBus();
BusFactory.setThreadDefaultBus(this.mcf.getBus());
Service svc;
try {
svc = Service.create(this.mcf.getServiceQName());
} finally {
BusFactory.setThreadDefaultBus(bus);
}
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with endpoint", endpoint);
}
svc.addPort(this.mcf.getPortQName(), binding, endpoint);
dispatch = svc.createDispatch(this.mcf.getPortQName(), type, mode);
configureWSSecurity(dispatch);
}
setDispatchProperties(dispatch, binding);
return dispatch;
}
use of javax.xml.ws.WebServiceException in project OpenOLAT by OpenOLAT.
the class ViteroManager method removeFromRoom.
public ViteroStatus removeFromRoom(ViteroBooking booking, int userId) throws VmsNotAvailableException {
try {
Groupiduserid groupuserId = new Groupiduserid();
groupuserId.setGroupid(booking.getGroupId());
groupuserId.setUserid(userId);
getGroupWebService().removeUserFromGroup(groupuserId);
return new ViteroStatus();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case userDoesntExist:
log.error("The user doesn ́t exist!", f);
break;
case groupDoesntExist:
log.error("The group doesn ́t exist", f);
break;
case invalidAttribut:
log.error("An id <= 0", f);
break;
default:
logAxisError("Cannot remove an user from a group", f);
}
return new ViteroStatus(code);
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot remove an user from a group", e);
return new ViteroStatus(ErrorCode.unkown);
}
}
use of javax.xml.ws.WebServiceException in project OpenOLAT by OpenOLAT.
the class ViteroManager method createBooking.
public ViteroStatus createBooking(BusinessGroup group, OLATResourceable ores, String subIdentifier, ViteroBooking vBooking) throws VmsNotAvailableException {
Bookingtype booking = getVmsBookingById(vBooking.getBookingId());
if (booking != null) {
log.info("Booking already exists: " + vBooking.getBookingId());
return new ViteroStatus();
}
try {
// a group per meeting
String groupName = vBooking.getGroupName();
int groupId = createGroup(groupName);
if (groupId < 0) {
return new ViteroStatus(ErrorCode.unkown);
}
vBooking.setGroupId(groupId);
// create the meeting with the new group
Booking bookingWs = getBookingWebService();
CreateBookingRequest createRequest = new CreateBookingRequest();
Newbookingtype newBooking = new Newbookingtype();
// mandatory
newBooking.setStart(format(vBooking.getStart()));
newBooking.setEnd(format(vBooking.getEnd()));
newBooking.setStartbuffer(vBooking.getStartBuffer());
newBooking.setEndbuffer(vBooking.getEndBuffer());
newBooking.setGroupid(groupId);
newBooking.setRoomsize(vBooking.getRoomSize());
newBooking.setTimezone(viteroModule.getTimeZoneId());
if (StringHelper.containsNonWhitespace(vBooking.getEventName())) {
newBooking.setEventname(vBooking.getEventName());
}
createRequest.setBooking(newBooking);
CreateBookingResponse response = bookingWs.createBooking(createRequest);
Boolean bookingCollision = response.isBookingcollision();
Boolean moduleCollision = response.isModulecollision();
int bookingId = response.getBookingid();
if (bookingCollision != null && bookingCollision.booleanValue()) {
return new ViteroStatus(ErrorCode.bookingCollision);
} else if (moduleCollision != null && moduleCollision.booleanValue()) {
return new ViteroStatus(ErrorCode.moduleCollision);
}
vBooking.setBookingId(bookingId);
getOrCreateProperty(group, ores, subIdentifier, vBooking);
return new ViteroStatus();
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
case invalidTimezone:
log.error("Invalid time zone!", f);
break;
case bookingCollision:
log.error("Booking collision!", f);
break;
case moduleCollision:
log.error("Invalid module selection!", f);
break;
case bookingInPast:
log.error("Booking in the past!", f);
break;
case licenseExpired:
log.error("License/customer expired!", f);
break;
default:
logAxisError("Cannot create a booking.", f);
}
return new ViteroStatus(code);
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot create a booking.", e);
return new ViteroStatus(ErrorCode.remoteException);
}
}
use of javax.xml.ws.WebServiceException in project OpenOLAT by OpenOLAT.
the class ViteroManager method getVmsUsersByGroup.
protected List<Usertype> getVmsUsersByGroup(int groupId) throws VmsNotAvailableException {
try {
GetUserListByGroupRequest listRequest = new GetUserListByGroupRequest();
listRequest.setGroupid(groupId);
Userlist userList = getUserWebService().getUserListByGroup(listRequest);
List<Usertype> userTypes = userList.getUser();
return userTypes;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default:
logAxisError("Cannot get the list of users in group: " + groupId, f);
}
return null;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
log.error("Cannot get the list of users in group: " + groupId, e);
return null;
}
}
Aggregations