use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class SimpleMethodDispatcher method getBindingOperation.
public BindingOperationInfo getBindingOperation(Method method, Endpoint endpoint) {
Map<BindingInfo, BindingOperationInfo> bops = infoMap.get(method);
if (bops == null) {
return null;
}
BindingOperationInfo bop = bops.get(endpoint.getEndpointInfo().getBinding());
if (bop == null) {
OperationInfo o = methodToOp.get(method);
if (o == null) {
return null;
}
BindingInfo b = endpoint.getEndpointInfo().getBinding();
for (BindingOperationInfo bop2 : b.getOperations()) {
if (bop2.getOperationInfo().equals(o)) {
bop2 = getRealOperation(o, bop2);
bops.put(b, bop2);
return bop2;
}
}
}
return bop;
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class AbstractInvoker method invoke.
public Object invoke(Exchange exchange, Object o) {
final Object serviceObject = getServiceObject(exchange);
try {
BindingOperationInfo bop = exchange.getBindingOperationInfo();
MethodDispatcher md = (MethodDispatcher) exchange.getService().get(MethodDispatcher.class.getName());
Method m = bop == null ? null : md.getMethod(bop);
if (m == null && bop == null) {
LOG.severe(new Message("MISSING_BINDING_OPERATION", LOG).toString());
throw new Fault(new Message("EXCEPTION_INVOKING_OBJECT", LOG, "No binding operation info", "unknown method", "unknown"));
}
List<Object> params = null;
if (o instanceof List) {
params = CastUtils.cast((List<?>) o);
} else if (o != null) {
params = new MessageContentsList(o);
}
m = adjustMethodAndParams(m, exchange, params, serviceObject.getClass());
// Method m = (Method)bop.getOperationInfo().getProperty(Method.class.getName());
m = matchMethod(m, serviceObject);
return invoke(exchange, serviceObject, m, params);
} finally {
releaseServiceObject(exchange, serviceObject);
}
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class RPCInInterceptor method handleMessage.
public void handleMessage(Message message) {
if (isGET(message)) {
LOG.fine("RPCInInterceptor skipped in HTTP GET method");
return;
}
DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
BindingOperationInfo operation = null;
if (!StaxUtils.toNextElement(xmlReader)) {
message.setContent(Exception.class, new RuntimeException("There must be a method name element."));
}
String opName = xmlReader.getLocalName();
if (isRequestor(message) && opName.endsWith("Response")) {
opName = opName.substring(0, opName.length() - 8);
}
if (message.getExchange().getBindingOperationInfo() == null) {
operation = getOperation(message, new QName(xmlReader.getNamespaceURI(), opName));
if (operation == null) {
// it's doc-lit-bare
new BareInInterceptor().handleMessage(message);
return;
}
setMessage(message, operation);
} else {
operation = message.getExchange().getBindingOperationInfo();
}
MessageInfo msg;
DataReader<XMLStreamReader> dr = getDataReader(message, XMLStreamReader.class);
if (!isRequestor(message)) {
msg = operation.getOperationInfo().getInput();
} else {
msg = operation.getOperationInfo().getOutput();
}
message.put(MessageInfo.class, msg);
MessageContentsList parameters = new MessageContentsList();
StaxUtils.nextEvent(xmlReader);
boolean hasNext = true;
Iterator<MessagePartInfo> itr = msg.getMessageParts().iterator();
while (itr.hasNext()) {
MessagePartInfo part = itr.next();
if (hasNext) {
hasNext = StaxUtils.toNextElement(xmlReader);
}
if (hasNext) {
QName qn = xmlReader.getName();
if (qn.equals(SOAP12_RESULT)) {
// just ignore this. The parts should work correctly.
try {
while (xmlReader.getEventType() != XMLStreamConstants.END_ELEMENT) {
xmlReader.next();
}
xmlReader.next();
} catch (XMLStreamException e) {
// ignore
}
StaxUtils.toNextElement(xmlReader);
qn = xmlReader.getName();
}
// WSI-BP states that RPC/Lit part accessors should be completely unqualified
// However, older toolkits (Axis 1.x) are qualifying them. We'll go
// ahead and just match on the localpart. The RPCOutInterceptor
// will always generate WSI-BP compliant messages so it's unknown if
// the non-WSI-BP toolkits will be able to understand the CXF
// generated messages if they are expecting it to be qualified.
Iterator<MessagePartInfo> partItr = msg.getMessageParts().iterator();
while (!qn.getLocalPart().equals(part.getConcreteName().getLocalPart()) && partItr.hasNext()) {
part = partItr.next();
}
// only check the localpart as explained above
if (!qn.getLocalPart().equals(part.getConcreteName().getLocalPart())) {
throw new Fault(new org.apache.cxf.common.i18n.Message("UNKNOWN_RPC_LIT_PART", LOG, qn));
}
try {
parameters.put(part, dr.read(part, xmlReader));
} catch (Fault f) {
if (!isRequestor(message)) {
f.setFaultCode(Fault.FAULT_CODE_CLIENT);
}
throw f;
}
}
}
message.setContent(List.class, parameters);
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class RPCOutInterceptor method handleMessage.
public void handleMessage(Message message) {
XMLStreamWriter origXmlWriter = null;
try {
NSStack nsStack = new NSStack();
nsStack.push();
BindingOperationInfo operation = message.getExchange().getBindingOperationInfo();
assert operation.getName() != null;
XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
CachingXmlEventWriter cache = null;
// need to cache the events in case validation fails or buffering is enabled
if (shouldBuffer(message)) {
origXmlWriter = xmlWriter;
cache = new CachingXmlEventWriter();
try {
cache.setNamespaceContext(xmlWriter.getNamespaceContext());
} catch (XMLStreamException e) {
// ignorable, will just get extra namespace decls
}
message.setContent(XMLStreamWriter.class, cache);
xmlWriter = cache;
}
List<MessagePartInfo> parts = null;
boolean output = false;
if (!isRequestor(message)) {
if (operation.getOutput() == null) {
return;
}
parts = operation.getOutput().getMessageParts();
output = true;
} else {
parts = operation.getInput().getMessageParts();
output = false;
}
MessageContentsList objs = MessageContentsList.getContentsList(message);
if (objs == null) {
addOperationNode(nsStack, message, xmlWriter, output, operation);
xmlWriter.writeEndElement();
return;
}
for (MessagePartInfo part : parts) {
if (objs.hasValue(part)) {
Object o = objs.get(part);
if (o == null) {
// WSI-BP R2211 - RPC/Lit parts are not allowed to be xsi:nil
throw new Fault(new org.apache.cxf.common.i18n.Message("BP_2211_RPCLIT_CANNOT_BE_NULL", LOG, part.getConcreteName()));
}
// WSI-BP R2737 -RPC/LIG part name space is empty
// part.setConcreteName(new QName("", part.getConcreteName().getLocalPart()));
}
}
addOperationNode(nsStack, message, xmlWriter, output, operation);
writeParts(message, message.getExchange(), operation, objs, parts);
// Finishing the writing.
xmlWriter.writeEndElement();
if (cache != null) {
try {
for (XMLEvent event : cache.getEvents()) {
StaxUtils.writeEvent(event, origXmlWriter);
}
} catch (XMLStreamException e) {
throw new Fault(e);
}
}
} catch (XMLStreamException e) {
throw new Fault(e);
} finally {
if (origXmlWriter != null) {
message.setContent(XMLStreamWriter.class, origXmlWriter);
}
}
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class SoapActionInInterceptor method getAndSetOperation.
public static void getAndSetOperation(SoapMessage message, String action, boolean strict) {
if (StringUtils.isEmpty(action)) {
return;
}
Exchange ex = message.getExchange();
Endpoint ep = ex.getEndpoint();
if (ep == null) {
return;
}
BindingOperationInfo bindingOp = null;
Collection<BindingOperationInfo> bops = ep.getEndpointInfo().getBinding().getOperations();
if (bops != null) {
for (BindingOperationInfo boi : bops) {
if (isActionMatch(message, boi, action)) {
if (bindingOp != null) {
// more than one op with the same action, will need to parse normally
return;
}
bindingOp = boi;
}
if (matchWSAAction(boi, action)) {
if (bindingOp != null && bindingOp != boi) {
// more than one op with the same action, will need to parse normally
return;
}
bindingOp = boi;
}
}
}
if (bindingOp == null) {
if (strict) {
// we didn't match the an operation, we'll try again later to make
// sure the incoming message did end up matching an operation.
// This could occur in some cases like WS-RM and WS-SecConv that will
// intercept the message with a new endpoint/operation
message.getInterceptorChain().add(new SoapActionInAttemptTwoInterceptor(action));
}
return;
}
ex.put(BindingOperationInfo.class, bindingOp);
}
Aggregations