use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class RMEndpoint method buildSequenceAckOperationInfo.
void buildSequenceAckOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
RMConstants consts = protocol.getConstants();
OperationInfo operationInfo = ii.addOperation(consts.getSequenceAckOperationName());
MessageInfo messageInfo = operationInfo.createMessage(consts.getSequenceAckOperationName(), MessageInfo.Type.INPUT);
operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class RMEndpoint method buildAckRequestedOperationInfo.
void buildAckRequestedOperationInfo(InterfaceInfo ii, ProtocolVariation protocol) {
RMConstants consts = protocol.getConstants();
OperationInfo operationInfo = ii.addOperation(consts.getAckRequestedOperationName());
MessageInfo messageInfo = operationInfo.createMessage(consts.getAckRequestedOperationName(), MessageInfo.Type.INPUT);
operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class OperationProcessor method processMethod.
void processMethod(JavaMethod method, OperationInfo operation) throws ToolException {
if (isAsyncMethod(method)) {
return;
}
MessageInfo inputMessage = operation.getInput();
MessageInfo outputMessage = operation.getOutput();
if (inputMessage == null) {
LOG.log(Level.WARNING, "NO_INPUT_MESSAGE", new Object[] { operation.getName() });
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("INVALID_MEP", LOG, new Object[] { operation.getName() });
throw new ToolException(msg);
}
ParameterProcessor paramProcessor = new ParameterProcessor(context);
method.clear();
JAXWSBinding opBinding = operation.getExtensor(JAXWSBinding.class);
JAXWSBinding ptBinding = operation.getInterface().getExtensor(JAXWSBinding.class);
JAXWSBinding defBinding = operation.getInterface().getService().getDescription().getExtensor(JAXWSBinding.class);
boolean enableAsync = false;
boolean enableMime = false;
boolean enableWrapper = method.isWrapperStyle();
if (defBinding != null) {
if (defBinding.isSetEnableMime()) {
enableMime = defBinding.isEnableMime();
}
if (defBinding.isSetEnableAsyncMapping()) {
enableAsync = defBinding.isEnableAsyncMapping();
}
if (defBinding.isSetEnableWrapperStyle()) {
enableWrapper = defBinding.isEnableWrapperStyle();
}
}
if (ptBinding != null) {
if (ptBinding.isSetEnableMime()) {
enableMime = ptBinding.isEnableMime();
}
if (ptBinding.isSetEnableAsyncMapping()) {
enableAsync = ptBinding.isEnableAsyncMapping();
}
if (ptBinding.isSetEnableWrapperStyle()) {
enableWrapper = ptBinding.isEnableWrapperStyle();
}
}
if (opBinding != null) {
if (opBinding.isSetEnableMime()) {
enableMime = opBinding.isEnableMime();
}
if (opBinding.isSetEnableAsyncMapping()) {
enableAsync = opBinding.isEnableAsyncMapping();
}
if (opBinding.isSetEnableWrapperStyle()) {
enableWrapper = opBinding.isEnableWrapperStyle();
}
}
enableWrapper = checkEnableWrapper(enableWrapper, method);
enableAsync = checkEnableAsync(enableAsync, method);
enableMime = checkEnableMime(enableMime, method);
method.setWrapperStyle(enableWrapper && method.isWrapperStyle());
paramProcessor.process(method, inputMessage, outputMessage, operation.getParameterOrdering());
if (method.isWrapperStyle()) {
setWrapper(operation);
method.annotate(new WrapperAnnotator(wrapperRequest, wrapperResponse));
}
method.annotate(new WebMethodAnnotator());
method.annotate(new WebResultAnnotator());
if (!method.isOneWay() && enableAsync && !isAddedAsycMethod(method)) {
addAsyncMethod(method);
}
if (enableMime) {
method.setMimeEnable(true);
}
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class ServiceProcessor method isNonWrappable.
private int isNonWrappable(BindingOperationInfo bop) {
QName operationName = bop.getName();
MessageInfo bodyMessage = null;
QName headerMessage = null;
boolean containParts = false;
boolean isSameMessage = false;
boolean allPartsHeader = false;
int result = NO_HEADER;
// begin process input
if (bop.getInput() != null && bop.getInput().getExtensors(ExtensibilityElement.class) != null) {
List<ExtensibilityElement> extensors = bop.getInput().getExtensors(ExtensibilityElement.class);
if (extensors != null) {
for (ExtensibilityElement ext : extensors) {
if (SOAPBindingUtil.isSOAPBody(ext)) {
bodyMessage = getMessage(operationName, true);
}
if (SOAPBindingUtil.isSOAPHeader(ext)) {
SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
headerMessage = header.getMessage();
if (header.getPart().length() > 0) {
containParts = true;
}
}
}
}
if (headerMessage != null && bodyMessage != null && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI()) && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
isSameMessage = true;
}
boolean isNonWrappable = isSameMessage && containParts;
// if is nonwrapple then return
if (isNonWrappable) {
result = IN_HEADER;
}
}
isSameMessage = false;
containParts = false;
// process output
if (bop.getOutput() != null && bop.getOutput().getExtensors(ExtensibilityElement.class) != null) {
List<ExtensibilityElement> extensors = bop.getOutput().getExtensors(ExtensibilityElement.class);
if (extensors != null) {
for (ExtensibilityElement ext : extensors) {
if (SOAPBindingUtil.isSOAPBody(ext)) {
bodyMessage = getMessage(operationName, false);
}
if (SOAPBindingUtil.isSOAPHeader(ext)) {
SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
headerMessage = header.getMessage();
if (header.getPart().length() > 0) {
containParts = true;
}
}
}
}
if (headerMessage != null && bodyMessage != null && headerMessage.getNamespaceURI().equalsIgnoreCase(bodyMessage.getName().getNamespaceURI()) && headerMessage.getLocalPart().equalsIgnoreCase(bodyMessage.getName().getLocalPart())) {
isSameMessage = true;
if (bodyMessage.getMessagePartsNumber() == 1) {
allPartsHeader = true;
}
}
boolean isNonWrappable = isSameMessage && containParts;
if (isNonWrappable && allPartsHeader) {
result = RESULT_HEADER;
}
if (isNonWrappable && !allPartsHeader) {
result = OUT_HEADER;
}
}
return result;
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class WSActionAnnotator method annotate.
public void annotate(JavaAnnotatable ja) {
JavaMethod method;
if (ja instanceof JavaMethod) {
method = (JavaMethod) ja;
} else {
throw new RuntimeException("Action can only annotate JavaMethod");
}
boolean required = false;
JavaInterface intf = method.getInterface();
MessageInfo inputMessage = operation.getInput();
MessageInfo outputMessage = operation.getOutput();
JAnnotation actionAnnotation = new JAnnotation(Action.class);
if (inputMessage.getExtensionAttributes() != null) {
String inputAction = getAction(inputMessage);
if (inputAction != null) {
actionAnnotation.addElement(new JAnnotationElement("input", inputAction));
required = true;
}
}
if (outputMessage != null && outputMessage.getExtensionAttributes() != null) {
String outputAction = getAction(outputMessage);
if (outputAction != null) {
actionAnnotation.addElement(new JAnnotationElement("output", outputAction));
required = true;
}
}
if (operation.hasFaults()) {
List<JAnnotation> faultAnnotations = new ArrayList<>();
for (FaultInfo faultInfo : operation.getFaults()) {
if (faultInfo.getExtensionAttributes() != null) {
String faultAction = getAction(faultInfo);
if (faultAction == null) {
continue;
}
JavaException exceptionClass = getExceptionClass(method, faultInfo);
if (!StringUtils.isEmpty(exceptionClass.getPackageName()) && !exceptionClass.getPackageName().equals(intf.getPackageName())) {
intf.addImport(exceptionClass.getClassName());
}
JAnnotation faultAnnotation = new JAnnotation(FaultAction.class);
faultAnnotation.addElement(new JAnnotationElement("className", exceptionClass));
faultAnnotation.addElement(new JAnnotationElement("value", faultAction));
faultAnnotations.add(faultAnnotation);
required = true;
}
}
actionAnnotation.addElement(new JAnnotationElement("fault", faultAnnotations));
}
if (required) {
method.addAnnotation("Action", actionAnnotation);
}
}
Aggregations