use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class ServiceJavascriptBuilder method begin.
@Override
public void begin(MessageInfo msg) {
if (isInUnwrappedOperation) {
return;
}
LOG.fine("Message " + msg.getName().toString());
Map<String, MessageInfo> nameMap;
Set<MessageInfo> conflicts;
if (msg.getType() == MessageInfo.Type.INPUT) {
nameMap = localInputMessagesNameMap;
conflicts = inputMessagesWithNameConflicts;
} else {
nameMap = localOutputMessagesNameMap;
conflicts = outputMessagesWithNameConflicts;
}
MessageInfo conflict = nameMap.get(msg.getName().getLocalPart());
if (conflict != null) {
conflicts.add(conflict);
conflicts.add(msg);
}
nameMap.put(msg.getName().getLocalPart(), msg);
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class ServiceJavascriptBuilder method buildOperationFunction.
private void buildOperationFunction(StringBuilder parameterList) {
String responseCallbackParams = "";
if (!currentOperation.isOneWay()) {
responseCallbackParams = "successCallback, errorCallback";
}
MessageInfo inputMessage = currentOperation.getInput();
code.append("//\n");
code.append("// Operation " + currentOperation.getName() + "\n");
if (!isWrapped) {
code.append("// - bare operation. Parameters:\n");
for (ParticleInfo ei : unwrappedElementsAndNames) {
code.append("// - " + getElementObjectName(ei) + "\n");
}
} else {
code.append("// Wrapped operation.\n");
QName contextQName = inputWrapperComplexType.getQName();
if (contextQName == null) {
contextQName = inputWrapperElement.getQName();
}
XmlSchemaSequence sequence = JavascriptUtils.getSequence(inputWrapperComplexType);
XmlSchema wrapperSchema = xmlSchemaCollection.getSchemaByTargetNamespace(contextQName.getNamespaceURI());
for (int i = 0; i < sequence.getItems().size(); i++) {
code.append("// parameter " + inputParameterNames.get(i) + "\n");
XmlSchemaSequenceMember sequenceItem = sequence.getItems().get(i);
ParticleInfo itemInfo = ParticleInfo.forLocalItem((XmlSchemaObject) sequenceItem, wrapperSchema, xmlSchemaCollection, prefixAccumulator, contextQName);
if (itemInfo.isArray()) {
code.append("// - array\n");
}
// null for an any.
XmlSchemaType type = itemInfo.getType();
if (type instanceof XmlSchemaComplexType) {
QName baseName;
if (type.getQName() != null) {
baseName = type.getQName();
} else {
baseName = ((XmlSchemaElement) sequenceItem).getQName();
}
code.append("// - Object constructor is " + nameManager.getJavascriptName(baseName) + "\n");
} else if (type != null) {
code.append("// - simple type " + type.getQName());
}
}
}
code.append("//\n");
code.append("function " + opFunctionGlobalName + "(" + responseCallbackParams + ((parameterList.length() > 0 && !currentOperation.isOneWay()) ? ", " : "") + parameterList + ") {\n");
utils.appendLine("this.client = new CxfApacheOrgClient(this.jsutils);");
utils.appendLine("var xml = null;");
if (inputMessage != null) {
utils.appendLine("var args = new Array(" + inputParameterNames.size() + ");");
int px = 0;
for (String param : inputParameterNames) {
utils.appendLine("args[" + px + "] = " + param + ";");
px++;
}
utils.appendLine("xml = this." + getFunctionPropertyName(inputMessagesWithNameConflicts, inputMessage, inputMessage.getName()) + "_serializeInput" + "(this.jsutils, args);");
}
// functions.
if (!currentOperation.isOneWay()) {
utils.appendLine("this.client.user_onsuccess = successCallback;");
utils.appendLine("this.client.user_onerror = errorCallback;");
utils.appendLine("var closureThis = this;");
// client will pass itself and the response XML.
utils.appendLine("this.client.onsuccess = function(client, responseXml) { closureThis." + opFunctionPropertyName + "_onsuccess(client, responseXml); };");
// client will pass itself.
utils.appendLine("this.client.onerror = function(client) { closureThis." + opFunctionPropertyName + "_onerror(client); };");
}
utils.appendLine("var requestHeaders = [];");
if (soapBindingInfo != null) {
String action = soapBindingInfo.getSoapAction(currentOperation);
utils.appendLine("requestHeaders['SOAPAction'] = '" + action + "';");
}
// default 'method' by passing null. Is there some place this lives in the
// service model?
String syncAsyncFlag;
if (currentOperation.isOneWay()) {
utils.appendLine("this.jsutils.trace('oneway operation');");
syncAsyncFlag = "false";
} else {
utils.appendLine("this.jsutils.trace('synchronous = ' + this.synchronous);");
syncAsyncFlag = "this.synchronous";
}
utils.appendLine("this.client.request(this.url, xml, null, " + syncAsyncFlag + ", requestHeaders);");
code.append("}\n\n");
code.append(currentInterfaceClassName + ".prototype." + opFunctionPropertyName + " = " + opFunctionGlobalName + ";\n\n");
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class AbstractInDatabindingInterceptor method getMessageInfo.
protected MessageInfo getMessageInfo(Message message, BindingOperationInfo operation, boolean requestor) {
MessageInfo msgInfo;
OperationInfo intfOp = operation.getOperationInfo();
if (requestor) {
msgInfo = intfOp.getOutput();
message.put(MessageInfo.class, intfOp.getOutput());
} else {
msgInfo = intfOp.getInput();
message.put(MessageInfo.class, intfOp.getInput());
}
return msgInfo;
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class JaxWsServiceFactoryBean method buildWSAActions.
private void buildWSAActions(OperationInfo operation, Method method) {
// nothing
if (method == null) {
return;
}
Action action = method.getAnnotation(Action.class);
Addressing addressing = method.getDeclaringClass().getAnnotation(Addressing.class);
if (action == null && addressing == null) {
return;
}
WebMethod wm = method.getAnnotation(WebMethod.class);
String inputAction = "";
if (action != null) {
inputAction = action.input();
}
if (wm != null && StringUtils.isEmpty(inputAction)) {
inputAction = wm.action();
}
if (StringUtils.isEmpty(inputAction)) {
inputAction = computeAction(operation, "Request");
}
if (action == null && addressing != null) {
operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
if (operation.getOutput() != null) {
operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, computeAction(operation, "Response"));
}
} else {
MessageInfo input = operation.getInput();
input.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
if (!StringUtils.isEmpty(action.input())) {
input.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
}
MessageInfo output = operation.getOutput();
if (output != null && !StringUtils.isEmpty(action.output())) {
output.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, action.output());
output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, action.output());
} else if (output != null) {
output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
}
FaultAction[] faultActions = action.fault();
if (faultActions != null && faultActions.length > 0 && operation.getFaults() != null) {
for (FaultAction faultAction : faultActions) {
FaultInfo faultInfo = getFaultInfo(operation, faultAction.className());
if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
}
if (operation.isUnwrappedCapable()) {
faultInfo = getFaultInfo(operation.getUnwrappedOperation(), faultAction.className());
if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
}
}
}
}
}
for (FaultInfo fi : operation.getFaults()) {
if (fi.getExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME) == null) {
String f = "/Fault/" + fi.getName().getLocalPart();
fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
if (operation.isUnwrappedCapable()) {
fi = operation.getUnwrappedOperation().getFault(fi.getName());
fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
}
}
}
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class DispatchImpl method addInvokeOperation.
private void addInvokeOperation(boolean oneWay) {
String name = oneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME;
ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();
OperationInfo opInfo = info.getInterface().addOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME);
MessageInfo mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Request"), Type.INPUT);
opInfo.setInput(name + "Request", mInfo);
MessagePartInfo mpi = mInfo.addMessagePart("parameters");
if (context == null) {
mpi.setTypeClass(cl);
}
mpi.setElement(true);
if (!oneWay) {
mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Response"), Type.OUTPUT);
opInfo.setOutput(name + "Response", mInfo);
mpi = mInfo.addMessagePart("parameters");
mpi.setElement(true);
if (context == null) {
mpi.setTypeClass(cl);
}
}
for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
bind.addOperation(bo);
}
}
Aggregations