Search in sources :

Example 76 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class WadlGeneratorTest method mockMessage.

private Message mockMessage(String baseAddress, String pathInfo, String query, List<ClassResourceInfo> cris) throws Exception {
    Message m = new MessageImpl();
    Exchange e = new ExchangeImpl();
    e.put(Service.class, new JAXRSServiceImpl(cris));
    m.setExchange(e);
    control.reset();
    ServletDestination d = control.createMock(ServletDestination.class);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();
    Endpoint endpoint = new EndpointImpl(null, null, epr);
    e.put(Endpoint.class, endpoint);
    endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance());
    e.setDestination(d);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    bi.getProperties();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, "GET");
    control.replay();
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) JAXRSServiceImpl(org.apache.cxf.jaxrs.JAXRSServiceImpl) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 77 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class WadlGeneratorJsonTest method mockMessage.

private Message mockMessage(String baseAddress, String pathInfo, String query, ClassResourceInfo cri) throws Exception {
    Message m = new MessageImpl();
    Exchange e = new ExchangeImpl();
    e.put(Service.class, new JAXRSServiceImpl(Collections.singletonList(cri)));
    m.setExchange(e);
    control.reset();
    ServletDestination d = control.createMock(ServletDestination.class);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();
    Endpoint endpoint = new EndpointImpl(null, null, epr);
    e.put(Endpoint.class, endpoint);
    e.setDestination(d);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    bi.getProperties();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, "GET");
    control.replay();
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) JAXRSServiceImpl(org.apache.cxf.jaxrs.JAXRSServiceImpl) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 78 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class ColocMessageObserver method setExchangeProperties.

protected void setExchangeProperties(Exchange exchange, Message m) {
    exchange.put(Bus.class, bus);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Service.class, endpoint.getService());
    exchange.put(Binding.class, endpoint.getBinding());
    // Setup the BindingOperationInfo
    QName opName = (QName) m.get(Message.WSDL_OPERATION);
    BindingInfo bi = endpoint.getEndpointInfo().getBinding();
    BindingOperationInfo boi = bi.getOperation(opName);
    if (boi != null && boi.isUnwrapped()) {
        boi = boi.getWrappedOperation();
    }
    exchange.put(BindingOperationInfo.class, boi);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 79 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class CorbaStreamFaultOutInterceptor method handleMessage.

public void handleMessage(Message msg) {
    CorbaMessage message = (CorbaMessage) msg;
    Exchange exchange = message.getExchange();
    CorbaDestination destination;
    Fault faultEx = null;
    if (message.getDestination() != null) {
        destination = (CorbaDestination) message.getDestination();
    } else {
        destination = (CorbaDestination) exchange.getDestination();
    }
    orb = (ORB) message.get(CorbaConstants.ORB);
    if (orb == null) {
        orb = exchange.get(ORB.class);
    }
    DataWriter<XMLStreamWriter> writer = getDataWriter(message);
    Throwable ex = message.getContent(Exception.class);
    // is a Fault instance and contains a detail object.
    if (ex.getCause() == null) {
        if ((ex instanceof Fault) && (((Fault) ex).getDetail() != null)) {
            faultEx = (Fault) ex;
        } else {
            throw new CorbaBindingException(ex);
        }
    } else {
        ex = ex.getCause();
    }
    if (ex instanceof InvocationTargetException) {
        ex = ex.getCause();
    }
    if (ex instanceof SystemException) {
        setSystemException(message, ex, destination);
        return;
    }
    String exClassName;
    if (faultEx == null) {
        // REVISIT, we should not have to depend on WebFault annotation
        // Try changing the fault name to the proper mangled java exception classname.
        WebFault fault = ex.getClass().getAnnotation(WebFault.class);
        if (fault == null) {
            throw new CorbaBindingException(ex);
        }
        exClassName = fault.name();
    } else {
        // JCGS: exClassName to be set to the exception name
        Element faultElement = (Element) faultEx.getDetail().getFirstChild();
        exClassName = faultElement.getLocalName();
    }
    // Get information about the operation being invoked from the WSDL
    // definition.
    // We need this to marshal data correctly
    BindingInfo bInfo = destination.getBindingInfo();
    String opName = message.getExchange().get(String.class);
    Iterator<BindingOperationInfo> iter = bInfo.getOperations().iterator();
    BindingOperationInfo bopInfo = null;
    OperationType opType = null;
    while (iter.hasNext()) {
        bopInfo = iter.next();
        if (bopInfo.getName().getLocalPart().equals(opName)) {
            opType = bopInfo.getExtensor(OperationType.class);
            break;
        }
    }
    if (opType == null) {
        throw new CorbaBindingException("Unable to find binding operation for " + opName);
    }
    OperationInfo opInfo = bopInfo.getOperationInfo();
    if (faultEx != null) {
        MessagePartInfo partInfo = getFaultMessagePartInfo(opInfo, new QName("", exClassName));
        if (partInfo != null) {
            exClassName = partInfo.getTypeQName().getLocalPart();
        }
    }
    RaisesType exType = getRaisesType(opType, exClassName, ex);
    try {
        if (exType != null) {
            if (faultEx != null) {
                setUserExceptionFromFaultDetail(message, faultEx.getDetail(), exType, opInfo, writer, exchange.getEndpoint().getEndpointInfo().getService());
            } else {
                setUserException(message, ex, exType, opInfo, writer, exchange.getEndpoint().getEndpointInfo().getService());
            }
        } else {
            throw new CorbaBindingException(ex);
        }
    } catch (Exception exp) {
        throw new CorbaBindingException(exp);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) Fault(org.apache.cxf.interceptor.Fault) WebFault(javax.xml.ws.WebFault) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(org.omg.CORBA.SystemException) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Exchange(org.apache.cxf.message.Exchange) WebFault(javax.xml.ws.WebFault) CorbaDestination(org.apache.cxf.binding.corba.CorbaDestination) RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) SystemException(org.omg.CORBA.SystemException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) BindingInfo(org.apache.cxf.service.model.BindingInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ORB(org.omg.CORBA.ORB)

Example 80 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.

the class CorbaDSIServant method init.

public void init(ORB theOrb, POA poa, CorbaDestination dest, MessageObserver observer, CorbaTypeMap map) {
    orb = theOrb;
    servantPOA = poa;
    destination = dest;
    incomingObserver = observer;
    typeMap = map;
    // Get the list of interfaces that this servant will support
    try {
        BindingType bindType = destination.getBindingInfo().getExtensor(BindingType.class);
        if (bindType == null) {
            throw new CorbaBindingException("Unable to determine corba binding information");
        }
        List<String> bases = bindType.getBases();
        interfaces = new ArrayList<>();
        interfaces.add(bindType.getRepositoryID());
        for (Iterator<String> iter = bases.iterator(); iter.hasNext(); ) {
            interfaces.add(iter.next());
        }
    } catch (java.lang.Exception ex) {
        LOG.log(Level.SEVERE, "Couldn't initialize the corba DSI servant");
        throw new CorbaBindingException(ex);
    }
    // Build the list of CORBA operations and the WSDL operations they map to.  Note that
    // the WSDL operation name may not always match the CORBA operation name.
    BindingInfo bInfo = destination.getBindingInfo();
    Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
    operationMap = new HashMap<>(bInfo.getOperations().size());
    while (i.hasNext()) {
        BindingOperationInfo bopInfo = i.next();
        OperationType opType = bopInfo.getExtensor(OperationType.class);
        if (opType != null) {
            operationMap.put(opType.getName(), bopInfo.getName());
        }
    }
}
Also used : CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) BindingInfo(org.apache.cxf.service.model.BindingInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Aggregations

BindingInfo (org.apache.cxf.service.model.BindingInfo)103 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)65 QName (javax.xml.namespace.QName)45 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)44 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)35 Test (org.junit.Test)29 Endpoint (org.apache.cxf.endpoint.Endpoint)28 OperationInfo (org.apache.cxf.service.model.OperationInfo)21 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)20 Service (org.apache.cxf.service.Service)18 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)17 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)17 Exchange (org.apache.cxf.message.Exchange)15 Message (org.apache.cxf.message.Message)13 ArrayList (java.util.ArrayList)11 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)11 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)11 MessageImpl (org.apache.cxf.message.MessageImpl)11 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)9 Bus (org.apache.cxf.Bus)8