use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class SoapBindingFactory method addOutOfBandParts.
private void addOutOfBandParts(final BindingOperationInfo bop, final javax.wsdl.Message msg, final SchemaCollection schemas, boolean isInput, final String partName) {
MessageInfo.Type type;
int nextId = 0;
MessageInfo minfo = bop.getOperationInfo().getInput();
if (minfo != null) {
for (MessagePartInfo part : minfo.getMessageParts()) {
if (part.getIndex() >= nextId) {
nextId = part.getIndex() + 1;
}
}
}
minfo = bop.getOperationInfo().getOutput();
if (minfo != null) {
for (MessagePartInfo part : minfo.getMessageParts()) {
if (part.getIndex() >= nextId) {
nextId = part.getIndex() + 1;
}
}
}
if (isInput) {
type = MessageInfo.Type.INPUT;
minfo = bop.getOperationInfo().getInput();
} else {
type = MessageInfo.Type.OUTPUT;
minfo = bop.getOperationInfo().getOutput();
}
if (minfo == null) {
minfo = new MessageInfo(bop.getOperationInfo(), type, msg.getQName());
}
buildMessage(minfo, msg, schemas, nextId, partName);
// for wrapped style
OperationInfo unwrapped = bop.getOperationInfo().getUnwrappedOperation();
if (unwrapped == null) {
return;
}
nextId = 0;
if (isInput) {
minfo = unwrapped.getInput();
type = MessageInfo.Type.INPUT;
if (minfo != null) {
for (MessagePartInfo part : minfo.getMessageParts()) {
if (part.getIndex() >= nextId) {
nextId = part.getIndex() + 1;
}
}
}
} else {
minfo = unwrapped.getOutput();
type = MessageInfo.Type.OUTPUT;
if (minfo != null) {
for (MessagePartInfo part : minfo.getMessageParts()) {
if (part.getIndex() >= nextId) {
nextId = part.getIndex() + 1;
}
}
}
}
if (minfo == null) {
minfo = new MessageInfo(unwrapped, type, msg.getQName());
}
buildMessage(minfo, msg, schemas, nextId, partName);
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class SoapBindingFactory method buildMessage.
private void buildMessage(MessageInfo minfo, javax.wsdl.Message msg, SchemaCollection schemas, int nextId, String partNameFilter) {
for (Part part : cast(msg.getParts().values(), Part.class)) {
if (StringUtils.isEmpty(partNameFilter) || part.getName().equals(partNameFilter)) {
if (StringUtils.isEmpty(part.getName())) {
throw new RuntimeException("Problem with WSDL: part element in message " + msg.getQName().getLocalPart() + " does not specify a name.");
}
QName pqname = new QName(minfo.getName().getNamespaceURI(), part.getName());
MessagePartInfo pi = minfo.getMessagePart(pqname);
if (pi != null && pi.getMessageInfo().getName().equals(msg.getQName())) {
continue;
}
pi = minfo.addOutOfBandMessagePart(pqname);
if (!minfo.getName().equals(msg.getQName())) {
pi.setMessageContainer(new MessageInfo(minfo.getOperation(), null, msg.getQName()));
}
if (part.getTypeName() != null) {
pi.setTypeQName(part.getTypeName());
pi.setElement(false);
pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
} else {
pi.setElementQName(part.getElementName());
pi.setElement(true);
pi.setXmlSchema(schemas.getElementByQName(part.getElementName()));
}
pi.setProperty(OUT_OF_BAND_HEADER, Boolean.TRUE);
pi.setProperty(HEADER, Boolean.TRUE);
pi.setIndex(nextId);
nextId++;
}
}
}
use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.
the class JaxWsServiceConfigurationTest method testGetInPartName.
@Test
public void testGetInPartName() throws Exception {
QName opName = new QName("http://cxf.com/", "sayHello");
Method sayHelloMethod = Hello.class.getMethod("sayHello", new Class[] { String.class, String.class });
ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
bean.setServiceClass(Hello.class);
JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean.getServiceConfigurations().get(0);
jwsc.setServiceFactory(bean);
OperationInfo op = si.getInterface().getOperation(opName);
op.setInput("input", new MessageInfo(op, MessageInfo.Type.INPUT, new QName("http://cxf.com/", "input")));
op.setOutput("output", new MessageInfo(op, MessageInfo.Type.OUTPUT, new QName("http://cxf.com/", "output")));
QName partName = jwsc.getInPartName(op, sayHelloMethod, 0);
assertEquals("get wrong in partName for first param", new QName("http://cxf.com/", "arg0"), partName);
op.getInput().addMessagePart(new QName("arg0"));
partName = jwsc.getInPartName(op, sayHelloMethod, 1);
assertEquals("get wrong in partName for first param", new QName("http://cxf.com/", "arg1"), partName);
}
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 ").append(currentOperation.getName()).append('\n');
if (!isWrapped) {
code.append("// - bare operation. Parameters:\n");
for (ParticleInfo ei : unwrappedElementsAndNames) {
code.append("// - ").append(getElementObjectName(ei)).append('\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 ").append(inputParameterNames.get(i)).append('\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 ").append(nameManager.getJavascriptName(baseName)).append('\n');
} else if (type != null) {
code.append("// - simple type ").append(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).append(".prototype.").append(opFunctionPropertyName).append(" = ").append(opFunctionGlobalName).append(";\n\n");
}
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);
}
Aggregations