use of javax.wsdl.Message in project carbon-apimgt by wso2.
the class WSDL11SOAPOperationExtractor method getSoapInputParameterModel.
/**
* Gets swagger input parameter model for a given soap operation
*
* @param bindingOperation soap operation
* @return list of swagger models for the parameters
* @throws APIMgtWSDLException
*/
private List<ModelImpl> getSoapInputParameterModel(BindingOperation bindingOperation) throws APIMgtWSDLException {
List<ModelImpl> inputParameterModelList = new ArrayList<>();
Operation operation = bindingOperation.getOperation();
if (operation != null) {
Input input = operation.getInput();
if (input != null) {
Message message = input.getMessage();
if (message != null) {
Map map = message.getParts();
for (Object obj : map.entrySet()) {
Map.Entry entry = (Map.Entry) obj;
Part part = (Part) entry.getValue();
if (part != null) {
if (part.getElementName() != null) {
inputParameterModelList.add(parameterModelMap.get(part.getElementName().getLocalPart()));
} else {
if (part.getTypeName() != null && parameterModelMap.containsKey(part.getTypeName().getLocalPart())) {
inputParameterModelList.add(parameterModelMap.get(part.getTypeName().getLocalPart()));
} else if (part.getTypeName() != null && parameterModelMap.containsKey(message.getQName().getLocalPart())) {
ModelImpl model = parameterModelMap.get(message.getQName().getLocalPart());
model.addProperty(part.getName(), getPropertyFromDataType(part.getTypeName().getLocalPart()));
parameterModelMap.put(model.getName(), model);
inputParameterModelList.add(model);
} else {
ModelImpl model;
if (parameterModelMap.get(message.getQName().getLocalPart()) != null) {
model = parameterModelMap.get(message.getQName().getLocalPart());
} else {
model = new ModelImpl();
model.setType(ObjectProperty.TYPE);
model.setName(message.getQName().getLocalPart());
}
if (getPropertyFromDataType(part.getTypeName().getLocalPart()) instanceof RefProperty) {
RefProperty property = (RefProperty) getPropertyFromDataType(part.getTypeName().getLocalPart());
property.set$ref(SOAPToRESTConstants.Swagger.DEFINITIONS_ROOT + part.getTypeName().getLocalPart());
model.addProperty(part.getName(), property);
} else {
model.addProperty(part.getName(), getPropertyFromDataType(part.getTypeName().getLocalPart()));
}
parameterModelMap.put(model.getName(), model);
inputParameterModelList.add(model);
}
}
}
}
}
}
}
return inputParameterModelList;
}
use of javax.wsdl.Message in project cxf by apache.
the class WSDLServiceBuilder method buildServices.
private List<ServiceInfo> buildServices(Definition def, Service serv, QName endpointName, DescriptionInfo d) {
Map<QName, ServiceInfo> services = new LinkedHashMap<>();
DescriptionInfo description = d;
if (null == description) {
description = new DescriptionInfo();
if (recordOriginal) {
description.setProperty(WSDL_DEFINITION, def);
}
description.setName(def.getQName());
description.setBaseURI(def.getDocumentBaseURI());
copyExtensors(description, def.getExtensibilityElements());
copyExtensionAttributes(description, def);
Set<Definition> done = new HashSet<>();
done.add(def);
Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
for (List<Import> imports : values) {
for (Import imp : imports) {
if (!done.contains(imp.getDefinition())) {
done.add(imp.getDefinition());
copyExtensors(description, imp.getExtensibilityElements());
copyExtensionAttributes(description, imp);
copyExtensors(description, imp.getDefinition().getExtensibilityElements());
copyExtensionAttributes(description, imp.getDefinition());
}
}
}
}
for (Port port : cast(serv.getPorts().values(), Port.class)) {
if (endpointName != null && !endpointName.getLocalPart().equals(port.getName())) {
continue;
}
Binding binding = port.getBinding();
PortType bindingPt = binding.getPortType();
if (bindingPt == null) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_MISSING_TYPE", LOG, binding.getQName());
throw new WSDLRuntimeException(msg);
}
// TODO: wsdl4j's bug. if there is recursive import,
// wsdl4j can not get operation input message
PortType pt = def.getPortType(bindingPt.getQName());
if (pt == null) {
pt = bindingPt;
}
ServiceInfo service = services.get(pt.getQName());
if (service == null) {
service = new ServiceInfo();
service.setDescription(description);
description.getDescribed().add(service);
if (recordOriginal) {
service.setProperty(WSDL_DEFINITION, def);
service.setProperty(WSDL_SERVICE, serv);
}
getSchemas(def, service);
copyDocumentation(service, serv);
service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
service.setTargetNamespace(def.getTargetNamespace());
service.setName(serv.getQName());
copyExtensors(service, serv.getExtensibilityElements());
copyExtensionAttributes(service, serv);
buildInterface(service, pt);
services.put(pt.getQName(), service);
}
BindingInfo bi = service.getBinding(binding.getQName());
if (bi == null) {
bi = buildBinding(service, binding);
}
buildEndpoint(service, bi, port);
}
return new ArrayList<>(services.values());
}
use of javax.wsdl.Message in project cxf by apache.
the class ExceptionVisitor method createFaultMessage.
private void createFaultMessage(QName qname) {
String exceptionName = qname.getLocalPart();
// messages
Message faultMsg = definition.createMessage();
faultMsg.setQName(new QName(definition.getTargetNamespace(), exceptionName));
faultMsg.setUndefined(false);
// message - part
Part part = definition.createPart();
part.setName("exception");
part.setElementName(qname);
faultMsg.addPart(part);
// add the fault element namespace to the definition
String nsURI = qname.getNamespaceURI();
manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
definition.addMessage(faultMsg);
}
use of javax.wsdl.Message in project cxf by apache.
the class OperationVisitor method generateInputMessage.
public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
Message msg = definition.createMessage();
QName msgName;
if (!mapper.isDefaultMapping()) {
// mangle the message name
// REVISIT, do we put in the entire scope for mangling
msgName = new QName(definition.getTargetNamespace(), getScope().tail() + "." + operation.getName());
} else {
msgName = new QName(definition.getTargetNamespace(), operation.getName());
}
msg.setQName(msgName);
msg.setUndefined(false);
String inputName = operation.getName() + REQUEST_SUFFIX;
Input input = definition.createInput();
input.setName(inputName);
input.setMessage(msg);
BindingInput bindingInput = definition.createBindingInput();
bindingInput.setName(inputName);
bindingOperation.setBindingInput(bindingInput);
operation.setInput(input);
definition.addMessage(msg);
return msg;
}
use of javax.wsdl.Message in project cxf by apache.
the class UniqueBodyPartsValidator method isValid.
public boolean isValid() {
Collection<Binding> bindings = CastUtils.cast(def.getAllBindings().values());
for (Binding binding : bindings) {
uniqueBodyPartsMap = new HashMap<>();
List<BindingOperation> ops = CastUtils.cast(binding.getBindingOperations());
for (BindingOperation op : ops) {
Operation operation = op.getOperation();
if (operation != null && operation.getInput() != null) {
Message inMessage = operation.getInput().getMessage();
BindingInput bin = op.getBindingInput();
Set<String> headers = new HashSet<>();
if (bin != null) {
List<ExtensibilityElement> lst = CastUtils.cast(bin.getExtensibilityElements());
for (ExtensibilityElement ext : lst) {
if (!(ext instanceof SOAPHeader)) {
continue;
}
SOAPHeader header = (SOAPHeader) ext;
if (!header.getMessage().equals(inMessage.getQName())) {
continue;
}
headers.add(header.getPart());
}
}
if (inMessage != null && !isUniqueBodyPart(operation.getName(), inMessage, headers, binding.getQName())) {
return false;
}
}
}
}
return true;
}
Aggregations