use of org.apache.cxf.binding.corba.CorbaBindingException in project cxf by apache.
the class CorbaStreamFaultOutInterceptor method getDataWriter.
protected DataWriter<XMLStreamWriter> getDataWriter(CorbaMessage message) {
Service serviceModel = ServiceModelUtil.getService(message.getExchange());
DataWriter<XMLStreamWriter> dataWriter = serviceModel.getDataBinding().createWriter(XMLStreamWriter.class);
if (dataWriter == null) {
throw new CorbaBindingException("Couldn't create data writer for outgoing fault message");
}
return dataWriter;
}
use of org.apache.cxf.binding.corba.CorbaBindingException in project cxf by apache.
the class CorbaStreamFaultOutInterceptor method setUserException.
protected void setUserException(CorbaMessage message, Throwable ex, RaisesType exType, OperationInfo opInfo, DataWriter<XMLStreamWriter> writer, ServiceInfo service) throws Exception {
QName exIdlType = exType.getException();
QName elName = new QName("", exIdlType.getLocalPart());
MessagePartInfo faultPart = getFaultMessagePartInfo(opInfo, elName);
if (faultPart == null) {
throw new CorbaBindingException("Coulnd't find the message fault part : " + elName);
}
Method faultMethod = ex.getClass().getMethod("getFaultInfo");
if (faultMethod == null) {
return;
}
Object fault = faultMethod.invoke(ex);
// one has not been created on the servant side which throws the UserException.
if (fault == null) {
Class<?> faultClass = faultMethod.getReturnType();
fault = faultClass.newInstance();
}
CorbaFaultStreamWriter faultWriter = new CorbaFaultStreamWriter(orb, exType, message.getCorbaTypeMap(), service);
writer.write(fault, faultPart, faultWriter);
CorbaObjectHandler[] objs = faultWriter.getCorbaObjects();
CorbaStreamable streamable = message.createStreamableObject(objs[0], elName);
message.setStreamableException(streamable);
}
use of org.apache.cxf.binding.corba.CorbaBindingException in project cxf by apache.
the class CorbaDSIServant method invoke.
public void invoke(ServerRequest request) throws CorbaBindingException {
String opName = request.operation();
QName requestOperation = operationMap.get(opName);
MessageImpl msgImpl = new MessageImpl();
msgImpl.setDestination(getDestination());
Exchange exg = new ExchangeImpl();
exg.put(String.class, requestOperation.getLocalPart());
exg.put(ORB.class, getOrb());
exg.put(ServerRequest.class, request);
msgImpl.setExchange(exg);
CorbaMessage msg = new CorbaMessage(msgImpl);
msg.setCorbaTypeMap(typeMap);
// If there's no output message part in our operation then it's a oneway op
BindingMessageInfo bindingMsgOutputInfo = null;
BindingOperationInfo bindingOpInfo = null;
try {
bindingOpInfo = this.destination.getEndPointInfo().getBinding().getOperation(requestOperation);
} catch (Exception ex) {
throw new CorbaBindingException("Invalid Request. Operation unknown: " + opName);
}
if (bindingOpInfo != null) {
bindingMsgOutputInfo = bindingOpInfo.getOutput();
if (bindingMsgOutputInfo == null) {
exg.setOneWay(true);
}
}
// invokes the interceptors
getObserver().onMessage(msg);
}
use of org.apache.cxf.binding.corba.CorbaBindingException in project cxf by apache.
the class CorbaObjectReader method readULong.
public long readULong() throws CorbaBindingException {
try {
long l = stream.read_ulong();
l &= 0xffffffffL;
return l;
} catch (org.omg.CORBA.MARSHAL ex) {
LOG.log(Level.SEVERE, "CorbaObjectReader: could not read unsigned long");
throw new CorbaBindingException("CorbaObjectReader: readULong MARSHAL exception", ex);
}
}
use of org.apache.cxf.binding.corba.CorbaBindingException in project cxf by apache.
the class CorbaObjectReader method initializeCorbaObjectHandler.
private CorbaObjectHandler initializeCorbaObjectHandler(CorbaObjectHandler template) {
Constructor<?> templateConstructor = template.getClass().getDeclaredConstructors()[0];
Object[] params = new Object[4];
// of a sequence and needs to have the name "item" in order
if (template.isRecursive()) {
// Revisit: Is this always the case?
params[0] = new QName("item");
} else {
params[0] = template.getName();
}
params[1] = template.getIdlType();
params[2] = template.getTypeCode();
params[3] = template.getType();
CorbaObjectHandler handler = null;
try {
handler = (CorbaObjectHandler) templateConstructor.newInstance(params);
// the template object.
if (template instanceof CorbaAnyHandler) {
((CorbaAnyHandler) handler).setTypeMap(((CorbaAnyHandler) template).getTypeMap());
}
} catch (java.lang.Exception ex) {
throw new CorbaBindingException("Unable to instantiate sequence element", ex);
}
if (template instanceof CorbaSequenceHandler) {
CorbaSequenceHandler templateSeq = (CorbaSequenceHandler) template;
((CorbaSequenceHandler) handler).setTemplateElement(templateSeq.getTemplateElement());
} else if (template instanceof CorbaStructHandler) {
CorbaStructHandler templateStruct = (CorbaStructHandler) template;
CorbaStructHandler struct = (CorbaStructHandler) handler;
struct.setRecursive(template.isRecursive());
List<CorbaObjectHandler> members = templateStruct.getMembers();
for (int i = 0; i < members.size(); i++) {
CorbaObjectHandler member = initializeCorbaObjectHandler(members.get(i));
struct.addMember(member);
}
} else if (template instanceof CorbaArrayHandler) {
CorbaArrayHandler templateArray = (CorbaArrayHandler) template;
CorbaArrayHandler array = (CorbaArrayHandler) handler;
List<CorbaObjectHandler> elements = templateArray.getElements();
for (int i = 0; i < elements.size(); i++) {
CorbaObjectHandler element = initializeCorbaObjectHandler(elements.get(i));
array.addElement(element);
}
} else if (template instanceof CorbaUnionHandler) {
CorbaUnionHandler templateUnion = (CorbaUnionHandler) template;
CorbaUnionHandler union = (CorbaUnionHandler) handler;
union.setRecursive(template.isRecursive());
union.setDiscriminator(initializeCorbaObjectHandler(templateUnion.getDiscriminator()));
List<CorbaObjectHandler> cases = templateUnion.getCases();
for (int i = 0; i < cases.size(); i++) {
union.addCase(initializeCorbaObjectHandler(cases.get(i)));
}
}
return handler;
}
Aggregations