Java Code Examples for org.apache.cxf.service.model.MessageInfo#getMessagePartsNumber()
The following examples show how to use
org.apache.cxf.service.model.MessageInfo#getMessagePartsNumber() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParameterProcessor.java From cxf with Apache License 2.0 | 5 votes |
private void processWrappedInput(JavaMethod method, MessageInfo inputMessage) throws ToolException { if (messagePartsNotUnique(inputMessage)) { processInput(method, inputMessage); return; } else if (inputMessage.getMessagePartsNumber() == 0) { return; } MessagePartInfo part = inputMessage.getFirstMessagePart(); List<QName> wrappedElements = ProcessorUtil.getWrappedElementQNames(context, part.getElementQName()); if ((wrappedElements == null || wrappedElements.isEmpty()) && countOutOfBandHeader(inputMessage) == 0) { return; } for (QName item : wrappedElements) { JavaParameter jp = getParameterFromQName(part.getElementQName(), item, JavaType.Style.IN, part); checkPartName(inputMessage, item, jp); if (StringUtils.isEmpty(part.getConcreteName().getNamespaceURI())) { jp.setTargetNamespace(""); } addParameter(part, method, jp); } // Adding out of band headers if (requireOutOfBandHeader() && countOutOfBandHeader(inputMessage) > 0) { for (MessagePartInfo hpart : inputMessage.getMessageParts()) { if (!isOutOfBandHeader(hpart)) { continue; } addParameter(hpart, method, getParameterFromPart(method, hpart, JavaType.Style.IN)); } } }
Example 2
Source File: DocLiteralInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private void getBindingOperationForEmptyBody(Collection<OperationInfo> operations, Endpoint ep, Exchange exchange) { // TO DO : check duplicate operation with no input and also check if the action matches for (OperationInfo op : operations) { MessageInfo bmsg = op.getInput(); int bPartsNum = bmsg.getMessagePartsNumber(); if (bPartsNum == 0 || (bPartsNum == 1 && Constants.XSD_ANYTYPE.equals(bmsg.getFirstMessagePart().getTypeQName()))) { BindingOperationInfo boi = ep.getEndpointInfo().getBinding().getOperation(op); exchange.put(BindingOperationInfo.class, boi); exchange.setOneWay(op.isOneWay()); } } }
Example 3
Source File: ParameterProcessor.java From cxf with Apache License 2.0 | 4 votes |
private boolean messagePartsNotUnique(final MessageInfo message) { int count = countOutOfBandHeader(message); return message.getMessagePartsNumber() - count > 1; }
Example 4
Source File: WrapperClassOutInterceptor.java From cxf with Apache License 2.0 | 4 votes |
public void handleMessage(Message message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo bop = ex.getBindingOperationInfo(); MessageInfo messageInfo = message.get(MessageInfo.class); if (messageInfo == null || bop == null || !bop.isUnwrapped()) { return; } BindingOperationInfo newbop = bop.getWrappedOperation(); MessageInfo wrappedMsgInfo; if (Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) { wrappedMsgInfo = newbop.getInput().getMessageInfo(); } else { wrappedMsgInfo = newbop.getOutput().getMessageInfo(); } Class<?> wrapped = null; if (wrappedMsgInfo.getMessagePartsNumber() > 0) { wrapped = wrappedMsgInfo.getFirstMessagePart().getTypeClass(); } if (wrapped != null) { MessagePartInfo firstMessagePart = wrappedMsgInfo.getFirstMessagePart(); MessageContentsList objs = MessageContentsList.getContentsList(message); WrapperHelper helper = firstMessagePart.getProperty("WRAPPER_CLASS", WrapperHelper.class); if (helper == null) { helper = getWrapperHelper(message, messageInfo, wrappedMsgInfo, wrapped, firstMessagePart); } if (helper == null) { return; } try { MessageContentsList newObjs = new MessageContentsList(); if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message) && helper instanceof AbstractWrapperHelper) { ((AbstractWrapperHelper)helper).setValidate(true); } Object o2 = helper.createWrapperObject(objs); newObjs.put(firstMessagePart, o2); for (MessagePartInfo p : messageInfo.getMessageParts()) { if (Boolean.TRUE.equals(p.getProperty(ReflectionServiceFactoryBean.HEADER))) { MessagePartInfo mpi = wrappedMsgInfo.getMessagePart(p.getName()); if (objs.hasValue(p)) { newObjs.put(mpi, objs.get(p)); } } } message.setContent(List.class, newObjs); } catch (Fault f) { throw f; } catch (Exception e) { throw new Fault(e); } // we've now wrapped the object, so use the wrapped binding op ex.put(BindingOperationInfo.class, newbop); if (messageInfo == bop.getOperationInfo().getInput()) { message.put(MessageInfo.class, newbop.getOperationInfo().getInput()); message.put(BindingMessageInfo.class, newbop.getInput()); } else if (messageInfo == bop.getOperationInfo().getOutput()) { message.put(MessageInfo.class, newbop.getOperationInfo().getOutput()); message.put(BindingMessageInfo.class, newbop.getOutput()); } } }
Example 5
Source File: XMLMessageOutInterceptor.java From cxf with Apache License 2.0 | 4 votes |
public void handleMessage(Message message) throws Fault { BindingOperationInfo boi = message.getExchange().getBindingOperationInfo(); MessageInfo mi; BindingMessageInfo bmi; if (isRequestor(message)) { mi = boi.getOperationInfo().getInput(); bmi = boi.getInput(); } else { mi = boi.getOperationInfo().getOutput(); bmi = boi.getOutput(); } XMLBindingMessageFormat xmf = bmi.getExtensor(XMLBindingMessageFormat.class); QName rootInModel = null; if (xmf != null) { rootInModel = xmf.getRootNode(); } final int mpn = mi.getMessagePartsNumber(); if (boi.isUnwrapped() || mpn == 1) { // wrapper out interceptor created the wrapper // or if bare-one-param new BareOutInterceptor().handleMessage(message); } else { if (rootInModel == null) { rootInModel = boi.getName(); } if (mpn == 0 && !boi.isUnwrapped()) { // write empty operation qname writeMessage(message, rootInModel, false); } else { // multi param, bare mode, needs write root node writeMessage(message, rootInModel, true); } } // in the end we do flush ;) XMLStreamWriter writer = message.getContent(XMLStreamWriter.class); try { writer.flush(); } catch (XMLStreamException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE, e)); } }