Search in sources :

Example 11 with BindingOperationInfo

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

the class ClientImpl method processResult.

protected Object[] processResult(Message message, Exchange exchange, BindingOperationInfo oi, Map<String, Object> resContext) throws Exception {
    Exception ex = null;
    // Check to see if there is a Fault from the outgoing chain if it's an out Message
    if (!message.get(Message.INBOUND_MESSAGE).equals(Boolean.TRUE)) {
        ex = message.getContent(Exception.class);
    }
    boolean mepCompleteCalled = false;
    if (ex != null) {
        completeExchange(exchange);
        mepCompleteCalled = true;
        if (message.getContent(Exception.class) != null) {
            throw ex;
        }
    }
    ex = message.getExchange().get(Exception.class);
    if (ex != null) {
        if (!mepCompleteCalled) {
            completeExchange(exchange);
        }
        throw ex;
    }
    // REVISIT
    // - use a protocol neutral no-content marker instead of 202?
    // - move the decoupled destination property name into api
    Integer responseCode = (Integer) exchange.get(Message.RESPONSE_CODE);
    if (null != responseCode && 202 == responseCode) {
        Endpoint ep = exchange.getEndpoint();
        if (null != ep && null != ep.getEndpointInfo() && null == ep.getEndpointInfo().getProperty("org.apache.cxf.ws.addressing.MAPAggregator.decoupledDestination")) {
            return null;
        }
    }
    // Wait for a response if we need to
    if (oi != null && !oi.getOperationInfo().isOneWay()) {
        waitResponse(exchange);
    }
    // leave the input stream open for the caller
    Boolean keepConduitAlive = (Boolean) exchange.get(Client.KEEP_CONDUIT_ALIVE);
    if (keepConduitAlive == null || !keepConduitAlive) {
        completeExchange(exchange);
    }
    // Grab the response objects if there are any
    List<Object> resList = null;
    Message inMsg = exchange.getInMessage();
    if (inMsg != null) {
        if (null != resContext) {
            resContext.putAll(inMsg);
            // remove the recursive reference if present
            resContext.remove(Message.INVOCATION_CONTEXT);
            responseContext.put(Thread.currentThread(), resContext);
        }
        resList = CastUtils.cast(inMsg.getContent(List.class));
    }
    // check for an incoming fault
    ex = getException(exchange);
    if (ex != null) {
        throw ex;
    }
    if (resList == null && oi != null && !oi.getOperationInfo().isOneWay()) {
        BindingOperationInfo boi = oi;
        if (boi.isUnwrapped()) {
            boi = boi.getWrappedOperation();
        }
        if (!boi.getOutput().getMessageParts().isEmpty()) {
            // we were supposed to get some output, but didn't
            throw new IllegalStateException("Response message did not contain proper response data. Expected: " + boi.getOutput().getMessageParts().get(0).getConcreteName());
        }
    }
    if (resList != null) {
        return resList.toArray();
    }
    return null;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) UncheckedException(org.apache.cxf.common.i18n.UncheckedException)

Example 12 with BindingOperationInfo

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

the class OperationInfoAuthorizingInterceptorTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    Exchange ex = setUpExchange();
    Service service = EasyMock.createMock(Service.class);
    ex.put(Service.class, service);
    MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class);
    EasyMock.expect(service.get(MethodDispatcher.class.getName())).andReturn(md).anyTimes();
    BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class);
    ex.put(BindingOperationInfo.class, boi);
    EasyMock.expect(md.getMethod(boi)).andReturn(null);
    OperationInfo opinfo = EasyMock.createMock(OperationInfo.class);
    EasyMock.expect(opinfo.getName()).andReturn(new QName("urn:test", "echo")).anyTimes();
    EasyMock.expect(boi.getOperationInfo()).andReturn(opinfo).anyTimes();
    EasyMock.replay(service, md, boi, opinfo);
}
Also used : Exchange(org.apache.cxf.message.Exchange) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) MethodDispatcher(org.apache.cxf.service.invoker.MethodDispatcher) Before(org.junit.Before)

Example 13 with BindingOperationInfo

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

the class SimpleAuthorizingInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    method = TestService.class.getMethod("echo", new Class[] {});
    Exchange ex = setUpExchange();
    Service service = EasyMock.createMock(Service.class);
    ex.put(Service.class, service);
    MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class);
    service.get(MethodDispatcher.class.getName());
    EasyMock.expectLastCall().andReturn(md);
    BindingOperationInfo boi = EasyMock.createMock(BindingOperationInfo.class);
    ex.put(BindingOperationInfo.class, boi);
    md.getMethod(boi);
    EasyMock.expectLastCall().andReturn(method);
    EasyMock.replay(service, md);
}
Also used : Exchange(org.apache.cxf.message.Exchange) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Service(org.apache.cxf.service.Service) MethodDispatcher(org.apache.cxf.service.invoker.MethodDispatcher) Before(org.junit.Before)

Example 14 with BindingOperationInfo

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

the class ServiceUtils method getSchemaValidationTypeFromModel.

private static SchemaValidationType getSchemaValidationTypeFromModel(Message message) {
    Exchange exchange = message.getExchange();
    if (exchange != null) {
        BindingOperationInfo boi = exchange.getBindingOperationInfo();
        Endpoint endpoint = exchange.getEndpoint();
        if (boi != null && endpoint != null) {
            SchemaValidationType validationType = null;
            OperationInfo opInfo = boi.getOperationInfo();
            EndpointInfo ep = endpoint.getEndpointInfo();
            if (opInfo != null) {
                validationType = getSchemaValidationTypeFromModel(opInfo);
                if (validationType == null && ep != null) {
                    validationType = getSchemaValidationTypeFromModel(ep);
                }
            }
            return validationType;
        }
    }
    // else
    return null;
}
Also used : Exchange(org.apache.cxf.message.Exchange) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) SchemaValidationType(org.apache.cxf.annotations.SchemaValidation.SchemaValidationType)

Example 15 with BindingOperationInfo

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

the class AbstractInDatabindingInterceptor method findMessagePart.

/**
 * Find the next possible message part in the message. If an operation in
 * the list of operations is no longer a viable match, it will be removed
 * from the Collection.
 *
 * @param exchange
 * @param operations
 * @param name
 * @param client
 * @param index
 */
protected MessagePartInfo findMessagePart(Exchange exchange, Collection<OperationInfo> operations, QName name, boolean client, int index, Message message) {
    Endpoint ep = exchange.getEndpoint();
    MessagePartInfo lastChoice = null;
    BindingOperationInfo lastBoi = null;
    BindingMessageInfo lastMsgInfo = null;
    BindingMessageInfo msgInfo = null;
    BindingOperationInfo boi = null;
    for (Iterator<OperationInfo> itr = operations.iterator(); itr.hasNext(); ) {
        OperationInfo op = itr.next();
        boi = ep.getEndpointInfo().getBinding().getOperation(op);
        if (boi == null) {
            continue;
        }
        if (client) {
            msgInfo = boi.getOutput();
        } else {
            msgInfo = boi.getInput();
        }
        if (msgInfo == null) {
            itr.remove();
            continue;
        }
        Collection<MessagePartInfo> bodyParts = msgInfo.getMessageParts();
        if (bodyParts.isEmpty() || bodyParts.size() <= index) {
            itr.remove();
            continue;
        }
        MessagePartInfo p = msgInfo.getMessageParts().get(index);
        if (name.getNamespaceURI() == null || name.getNamespaceURI().length() == 0) {
            // message part has same namespace with the message
            name = new QName(p.getMessageInfo().getName().getNamespaceURI(), name.getLocalPart());
        }
        if (name.equals(p.getConcreteName())) {
            exchange.put(BindingOperationInfo.class, boi);
            exchange.setOneWay(op.isOneWay());
            return p;
        }
        if (Constants.XSD_ANYTYPE.equals(p.getTypeQName())) {
            lastChoice = p;
            lastBoi = boi;
            lastMsgInfo = msgInfo;
        } else {
            itr.remove();
        }
    }
    if (lastChoice != null) {
        setMessage(message, lastBoi, client, lastBoi.getBinding().getService(), lastMsgInfo.getMessageInfo());
    }
    return lastChoice;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo)

Aggregations

BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)214 QName (javax.xml.namespace.QName)82 BindingInfo (org.apache.cxf.service.model.BindingInfo)57 Test (org.junit.Test)55 Exchange (org.apache.cxf.message.Exchange)50 OperationInfo (org.apache.cxf.service.model.OperationInfo)47 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)42 Endpoint (org.apache.cxf.endpoint.Endpoint)41 Message (org.apache.cxf.message.Message)36 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)32 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)31 Service (org.apache.cxf.service.Service)29 Fault (org.apache.cxf.interceptor.Fault)24 MessageInfo (org.apache.cxf.service.model.MessageInfo)24 MessageContentsList (org.apache.cxf.message.MessageContentsList)23 Method (java.lang.reflect.Method)22 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)22 ArrayList (java.util.ArrayList)21 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)16