use of org.apache.cxf.binding.corba.wsdl.RaisesType in project cxf by apache.
the class CorbaConduit method buildRequest.
public void buildRequest(CorbaMessage message, OperationType opType) throws Exception {
ServiceInfo service = message.getExchange().getEndpoint().getEndpointInfo().getService();
NVList nvlist = getArguments(message);
NamedValue ret = getReturn(message);
Map<TypeCode, RaisesType> exceptions = getOperationExceptions(opType, typeMap);
ExceptionList exList = getExceptionList(exceptions, message, opType);
Request request = getRequest(message, opType.getName(), nvlist, ret, exList);
if (request == null) {
throw new CorbaBindingException("Couldn't build the corba request");
}
Exception ex = null;
try {
request.invoke();
ex = request.env().exception();
} catch (SystemException sysex) {
ex = sysex;
}
if (ex != null) {
if (ex instanceof SystemException) {
message.setContent(Exception.class, new Fault(ex));
message.setSystemException((SystemException) ex);
return;
}
if (ex instanceof UnknownUserException) {
UnknownUserException userEx = (UnknownUserException) ex;
Any except = userEx.except;
RaisesType raises = exceptions.get(except.type());
if (raises == null) {
throw new CorbaBindingException("Couldn't find the exception type code to unmarshall");
}
QName elName = new QName("", raises.getException().getLocalPart());
CorbaObjectHandler handler = CorbaHandlerUtils.initializeObjectHandler(orb, elName, raises.getException(), typeMap, service);
CorbaStreamable exStreamable = message.createStreamableObject(handler, elName);
exStreamable._read(except.create_input_stream());
message.setStreamableException(exStreamable);
message.setContent(Exception.class, new Fault(userEx));
} else {
message.setContent(Exception.class, new Fault(ex));
}
}
}
use of org.apache.cxf.binding.corba.wsdl.RaisesType in project cxf by apache.
the class OperationVisitor method createFaultMessage.
private void createFaultMessage(CorbaTypeImpl corbaType, Operation operation, BindingOperation bindingOperation, QName elementQName) {
String exceptionName = corbaType.getQName().getLocalPart();
Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
if (faultDef == null) {
faultDef = definition;
}
Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
if (faultMsg == null) {
throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
}
// porttype - operation - fault
Fault fault = definition.createFault();
fault.setMessage(faultMsg);
fault.setName(faultMsg.getQName().getLocalPart());
operation.addFault(fault);
// binding - operation - corba:operation - corba:raises
RaisesType raisesType = new RaisesType();
raisesType.setException(new QName(typeMap.getTargetNamespace(), exceptionName));
corbaOperation.getRaises().add(raisesType);
// binding - operation - fault
BindingFault bindingFault = definition.createBindingFault();
bindingFault.setName(faultMsg.getQName().getLocalPart());
bindingOperation.addBindingFault(bindingFault);
// add the fault element namespace to the definition
String nsURI = elementQName.getNamespaceURI();
manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
}
use of org.apache.cxf.binding.corba.wsdl.RaisesType in project cxf by apache.
the class WSDLToCorbaBinding method addCorbaOperationExtElement.
private void addCorbaOperationExtElement(BindingOperation bo, Operation op) throws Exception {
OperationType operationType = null;
try {
operationType = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
} catch (WSDLException wse) {
LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
throw new Exception(LOG.toString(), wse);
}
operationType.setName(op.getName());
List<ParamType> params = new ArrayList<>();
List<ArgType> returns = new ArrayList<>();
wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);
for (ParamType paramtype : params) {
operationType.getParam().add(paramtype);
}
for (ArgType retType : returns) {
operationType.setReturn(retType);
}
Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
for (Fault fault : faults) {
RaisesType raisestype = new RaisesType();
CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
if (extype != null) {
raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
operationType.getRaises().add(raisestype);
}
}
bo.addExtensibilityElement((ExtensibilityElement) operationType);
}
use of org.apache.cxf.binding.corba.wsdl.RaisesType in project cxf by apache.
the class WSDLToIDLAction method createIdlOperation.
public void createIdlOperation(org.apache.cxf.binding.corba.wsdl.OperationType opType, String name, boolean isOneway) throws Exception {
IdlOperation idlOp = IdlOperation.create(intf, opType.getName(), isOneway);
intf.holdForScope(idlOp);
ArgType crt = opType.getReturn();
if (crt != null) {
IdlType rt = findType(crt.getIdltype());
idlOp.addReturnType(rt);
}
for (ParamType arg : opType.getParam()) {
IdlType type = findType(arg.getIdltype());
String mode = arg.getMode().value();
IdlParam param = IdlParam.create(idlOp, arg.getName(), type, mode);
idlOp.addParameter(param);
}
for (RaisesType rs : opType.getRaises()) {
IdlType type = findType(rs.getException());
if (type instanceof IdlException) {
idlOp.addException((IdlException) type);
} else {
String msgStr = type.fullName() + " is not a type.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
}
root.flush();
intf.promoteHeldToScope();
}
use of org.apache.cxf.binding.corba.wsdl.RaisesType in project cxf by apache.
the class CorbaConduit method getOperationExceptions.
public Map<TypeCode, RaisesType> getOperationExceptions(OperationType operation, CorbaTypeMap map) {
if (orb == null) {
prepareOrb();
}
Map<TypeCode, RaisesType> exceptions = new HashMap<>();
List<RaisesType> exList = operation.getRaises();
if (exList != null) {
for (int i = 0; i < exList.size(); ++i) {
RaisesType ex = exList.get(i);
TypeCode tc = CorbaUtils.getTypeCode(orb, ex.getException(), map);
exceptions.put(tc, ex);
}
}
return exceptions;
}
Aggregations