Search in sources :

Example 1 with CorbaBindingException

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;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) Service(org.apache.cxf.service.Service)

Example 2 with CorbaBindingException

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);
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) CorbaFaultStreamWriter(org.apache.cxf.binding.corba.runtime.CorbaFaultStreamWriter) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) Method(java.lang.reflect.Method) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Example 3 with CorbaBindingException

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);
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) QName(javax.xml.namespace.QName) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException)

Example 4 with CorbaBindingException

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);
    }
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException)

Example 5 with CorbaBindingException

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;
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) QName(javax.xml.namespace.QName) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) CorbaStructHandler(org.apache.cxf.binding.corba.types.CorbaStructHandler) CorbaUnionHandler(org.apache.cxf.binding.corba.types.CorbaUnionHandler) CorbaArrayHandler(org.apache.cxf.binding.corba.types.CorbaArrayHandler) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) ArrayList(java.util.ArrayList) List(java.util.List) CorbaAnyHandler(org.apache.cxf.binding.corba.types.CorbaAnyHandler)

Aggregations

CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)25 QName (javax.xml.namespace.QName)8 TypeCode (org.omg.CORBA.TypeCode)5 URISyntaxException (java.net.URISyntaxException)4 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)4 CorbaMessage (org.apache.cxf.binding.corba.CorbaMessage)3 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)3 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)3 SystemException (org.omg.CORBA.SystemException)3 Method (java.lang.reflect.Method)2 URI (java.net.URI)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)2 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)2 Enum (org.apache.cxf.binding.corba.wsdl.Enum)2 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)2 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)2 Fault (org.apache.cxf.interceptor.Fault)2 Exchange (org.apache.cxf.message.Exchange)2