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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations