use of javax.wsdl.Message in project cxf by apache.
the class WSDLASTVisitor method getLogicalDefinition.
// Gets the logical definition for a file - an import will be added for the
// schema types if -T is used and a separate schema file generated.
// if -n is used an import will be added for the schema types and no types generated.
private Definition getLogicalDefinition(String schemaFilename, Writer schemaWriter) throws WSDLException, JAXBException, Exception {
Definition def = manager.createWSDLDefinition(targetNamespace);
// checks for -T option.
if (schemaFilename != null) {
writeSchemaDefinition(definition, schemaWriter);
manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), schemaFilename);
} else {
// checks for -n option
if (importSchemaFilename == null) {
Types types = definition.getTypes();
def.setTypes(types);
} else {
manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), importSchemaFilename);
}
}
Collection<PortType> portTypes = CastUtils.cast(definition.getAllPortTypes().values());
for (PortType port : portTypes) {
def.addPortType(port);
}
Collection<Message> messages = CastUtils.cast(definition.getMessages().values());
for (Message msg : messages) {
def.addMessage(msg);
}
Collection<String> namespaces = CastUtils.cast(definition.getNamespaces().values());
for (String namespace : namespaces) {
String prefix = definition.getPrefix(namespace);
if (!"corba".equals(prefix)) {
def.addNamespace(prefix, namespace);
} else {
def.removeNamespace(prefix);
}
}
Collection<Import> imports = CastUtils.cast(definition.getImports().values());
for (Import importType : imports) {
def.addImport(importType);
}
def.setDocumentationElement(definition.getDocumentationElement());
def.setDocumentBaseURI(definition.getDocumentBaseURI());
return def;
}
use of javax.wsdl.Message in project cxf by apache.
the class WSDLParameter method processWrappedInputParams.
private void processWrappedInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
Input input = operation.getInput();
if (input != null) {
Message msg = input.getMessage();
Part part = (Part) msg.getOrderedParts(null).iterator().next();
XmlSchemaElement el = getElement(part, xmlSchemaList);
if (el == null) {
return;
}
XmlSchemaComplexType schemaType = null;
if (el.getSchemaType() != null) {
schemaType = (XmlSchemaComplexType) el.getSchemaType();
}
XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
if (seq != null) {
for (XmlSchemaSequenceMember seqItem : seq.getItems()) {
if (seqItem instanceof XmlSchemaElement) {
el = (XmlSchemaElement) seqItem;
// REVISIT, handle element ref's?
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName, el.isNillable());
ParamType paramtype = createParam(wsdlToCorbaBinding, "in", el.getQName().getLocalPart(), idltype);
if (paramtype != null) {
inputs.add(paramtype);
}
}
}
}
}
}
use of javax.wsdl.Message in project cxf by apache.
the class WSDLParameter method isWrappedOperation.
private boolean isWrappedOperation(Operation op, SchemaCollection xmlSchemaList) throws Exception {
Message inputMessage = op.getInput().getMessage();
Message outputMessage = null;
if (op.getOutput() != null) {
outputMessage = op.getOutput().getMessage();
}
boolean passedRule = true;
// input message must exist
if (inputMessage == null || inputMessage.getParts().size() != 1 || (outputMessage != null && outputMessage.getParts().size() > 1)) {
passedRule = false;
}
if (!passedRule) {
return false;
}
XmlSchemaElement inputEl = null;
XmlSchemaElement outputEl = null;
// RULE No.2:
// The input message part refers to a global element decalration whose
// localname
// is equal to the operation name
Part inputPart = (Part) inputMessage.getParts().values().iterator().next();
if (inputPart.getElementName() == null) {
passedRule = false;
} else {
QName inputElementName = inputPart.getElementName();
inputEl = getElement(inputPart, xmlSchemaList);
if (inputEl == null || !op.getName().equals(inputElementName.getLocalPart())) {
passedRule = false;
}
}
if (!passedRule) {
return false;
}
// The output message part refers to a global element declaration
if (outputMessage != null && outputMessage.getParts().size() == 1) {
Part outputPart = (Part) outputMessage.getParts().values().iterator().next();
if (outputPart != null) {
if ((outputPart.getElementName() == null) || getElement(outputPart, xmlSchemaList) == null) {
passedRule = false;
} else {
outputEl = getElement(outputPart, xmlSchemaList);
}
}
}
if (!passedRule) {
return false;
}
if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xsct = (XmlSchemaComplexType) inputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
} else {
passedRule = false;
}
if (!passedRule) {
return false;
}
if (outputMessage != null) {
if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xsct = (XmlSchemaComplexType) outputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
} else {
passedRule = false;
}
}
return passedRule;
}
use of javax.wsdl.Message in project tesb-studio-se by Talend.
the class PublishMetadataRunnable method getAllPaths.
@SuppressWarnings("unchecked")
private Collection<String> getAllPaths() throws URISyntaxException {
final Set<String> paths = new HashSet<String>();
final Set<QName> portTypes = new HashSet<QName>();
final Set<QName> alreadyCreated = new HashSet<QName>();
for (Binding binding : (Collection<Binding>) wsdlDefinition.getAllBindings().values()) {
final QName portType = binding.getPortType().getQName();
if (portTypes.add(portType)) {
for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
Operation oper = operation.getOperation();
Input inDef = oper.getInput();
if (inDef != null) {
Message inMsg = inDef.getMessage();
addParamsToPath(portType, oper, inMsg, paths, alreadyCreated);
}
Output outDef = oper.getOutput();
if (outDef != null) {
Message outMsg = outDef.getMessage();
addParamsToPath(portType, oper, outMsg, paths, alreadyCreated);
}
for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
Message faultMsg = fault.getMessage();
addParamsToPath(portType, oper, faultMsg, paths, alreadyCreated);
}
}
}
}
return paths;
}
use of javax.wsdl.Message in project pentaho-kettle by pentaho.
the class WsdlOpFaultList method getFault.
/**
* Create a WsdlOpFault from the Fault.
*
* @param fault
* Fault to process.
* @return WsdlOpFault Result of processing.
*/
@SuppressWarnings("unchecked")
private WsdlOpFault getFault(Fault fault) throws KettleStepException {
Message m = fault.getMessage();
// a fault should only have one message part.
Map<?, Part> partMap = m.getParts();
if (partMap.size() != 1) {
throw new IllegalArgumentException("Invalid part count for fault!!");
}
Part faultPart = partMap.values().iterator().next();
boolean complexType = false;
// type of fault is specified either in Part's type or element attribute.
QName type = faultPart.getTypeName();
if (type == null) {
type = faultPart.getElementName();
Element schemaElement = _wsdlTypes.findNamedElement(type);
type = _wsdlTypes.getTypeQName(schemaElement.getAttribute("type"));
complexType = true;
}
return new WsdlOpFault(fault.getName(), type, complexType, _wsdlTypes);
}
Aggregations