use of javax.wsdl.Fault in project carbon-business-process by wso2.
the class SOAPUtils method buildSoapDetail.
private static OMElement buildSoapDetail(final BPELMessageContext bpelMessageContext, final MessageExchange odeMessageContext) throws AxisFault {
Element message = odeMessageContext.getResponse().getMessage();
QName faultName = odeMessageContext.getFault();
Operation operation = odeMessageContext.getOperation();
SOAPFactory soapFactory = bpelMessageContext.getSoapFactoryForCurrentMessageFlow();
if (faultName.getNamespaceURI() == null) {
return toFaultDetail(message, soapFactory);
}
Fault f = operation.getFault(faultName.getLocalPart());
if (f == null) {
return toFaultDetail(message, soapFactory);
}
// For faults, there will be exactly one part.
Part p = (Part) f.getMessage().getParts().values().iterator().next();
if (p == null) {
return toFaultDetail(message, soapFactory);
}
Element partEl = DOMUtils.findChildByName(message, new QName(null, p.getName()));
if (partEl == null) {
return toFaultDetail(message, soapFactory);
}
Element detail = DOMUtils.findChildByName(partEl, p.getElementName());
if (detail == null) {
return toFaultDetail(message, soapFactory);
}
return OMUtils.toOM(detail, soapFactory);
}
use of javax.wsdl.Fault in project tesb-studio-se by Talend.
the class PublishMetadataRunnable method process.
@SuppressWarnings("unchecked")
private void process(Definition wsdlDefinition, Collection<XmlFileConnectionItem> selectTables) throws Exception, CoreException {
List<IFile> tempFiles = new ArrayList<IFile>();
try {
File wsdlFile = null;
String baseUri = wsdlDefinition.getDocumentBaseURI();
URI uri = new URI(baseUri);
if ("file".equals(uri.getScheme())) {
wsdlFile = new File(uri.toURL().getFile());
} else {
Map<String, InputStream> load = new WSDLLoader().load(baseUri, "tempWsdl" + "%d.wsdl");
InputStream inputStream = load.remove(WSDLLoader.DEFAULT_FILENAME);
String name = File.createTempFile("tESBConsumer", ".wsdl").getName();
IFile tempWsdlFile = createTempFile(name, inputStream);
tempFiles.add(tempWsdlFile);
wsdlFile = new File(tempWsdlFile.getLocation().toPortableString());
// TESB-19040:save import wsdl files
if (!load.isEmpty()) {
for (Map.Entry<String, InputStream> importWsdl : load.entrySet()) {
tempFiles.add(createTempFile(importWsdl.getKey(), importWsdl.getValue()));
}
}
}
if (populationUtil == null) {
populationUtil = new WSDLPopulationUtil();
populationUtil.loadWSDL("file://" + wsdlFile.getAbsolutePath());
}
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();
if (inMsg != null) {
// fix for TDI-20699
List<QName> messageParts = getMessageParts(inMsg);
if (messageParts.isEmpty()) {
continue;
}
for (QName messagePart : messageParts) {
if (alreadyCreated.add(messagePart)) {
XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
}
}
}
}
Output outDef = oper.getOutput();
if (outDef != null) {
Message outMsg = outDef.getMessage();
if (outMsg != null) {
List<QName> messageParts = getMessageParts(outMsg);
if (messageParts.isEmpty()) {
continue;
}
for (QName messagePart : messageParts) {
if (alreadyCreated.add(messagePart)) {
XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
}
}
}
}
for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
Message faultMsg = fault.getMessage();
if (faultMsg != null) {
List<QName> messageParts = getMessageParts(faultMsg);
if (messageParts.isEmpty()) {
continue;
}
for (QName messagePart : messageParts) {
if (alreadyCreated.add(messagePart)) {
XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
}
}
}
}
}
}
}
} catch (Exception e) {
throw e;
} finally {
for (IFile tempFile : tempFiles) {
tempFile.delete(true, null);
}
}
}
use of javax.wsdl.Fault in project tomee by apache.
the class HeavyweightOperationInfoBuilder method buildOperationInfo.
public JaxRpcOperationInfo buildOperationInfo() throws OpenEJBException {
if (operationInfo != null) {
return operationInfo;
}
operationInfo = new JaxRpcOperationInfo();
operationInfo.name = operationName;
// Binding style rpc/encoded, doc/lit, wrapped, etc.
operationInfo.bindingStyle = bindingStyle;
// Operation style one way, request response, etc/
operationInfo.operationStyle = operationStyle;
// Java method name
operationInfo.javaMethodName = methodMapping.getJavaMethodName();
//
// Map the parameters
//
mapParameters();
//
if (methodMapping.getWsdlReturnValueMapping() != null) {
mapReturnType();
}
// Validate output mapping is complete
if (outputMessage != null && bindingStyle.isWrapped()) {
Part inputPart = getWrappedPart(outputMessage);
QName wrapperName = inputPart.getElementName();
XmlElementInfo wraperElement = schemaInfo.elements.get(wrapperName);
XmlTypeInfo wrapperType = schemaInfo.types.get(wraperElement.xmlType);
Set<String> expectedOutParams = new HashSet<>();
for (XmlElementInfo expectedOutParam : wrapperType.elements.values()) {
expectedOutParams.add(expectedOutParam.qname.getLocalPart());
}
if (!outParamNames.equals(expectedOutParams)) {
throw new OpenEJBException("Not all wrapper children were mapped to parameters or a return value for operation " + operationName);
}
} else if (null != outputMessage) {
if (!outParamNames.equals(outputMessage.getParts().keySet())) {
throw new OpenEJBException("Not all output message parts were mapped to parameters or a return value for operation " + operationName);
}
}
//
for (Fault fault : faults) {
JaxRpcFaultInfo faultInfo = mapFaults(fault);
operationInfo.faults.add(faultInfo);
}
return operationInfo;
}
use of javax.wsdl.Fault in project cxf by apache.
the class OperationVisitor method createFaultMessage.
private void createFaultMessage(CorbaTypeImpl corbaType, Operation operation, BindingOperation bindingOperation, QName elementQName) {
String exceptionName = corbaType.getQName().getLocalPart();
Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
if (faultDef == null) {
faultDef = definition;
}
Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
if (faultMsg == null) {
throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
}
// porttype - operation - fault
Fault fault = definition.createFault();
fault.setMessage(faultMsg);
fault.setName(faultMsg.getQName().getLocalPart());
operation.addFault(fault);
// binding - operation - corba:operation - corba:raises
RaisesType raisesType = new RaisesType();
raisesType.setException(new QName(typeMap.getTargetNamespace(), exceptionName));
corbaOperation.getRaises().add(raisesType);
// binding - operation - fault
BindingFault bindingFault = definition.createBindingFault();
bindingFault.setName(faultMsg.getQName().getLocalPart());
bindingOperation.addBindingFault(bindingFault);
// add the fault element namespace to the definition
String nsURI = elementQName.getNamespaceURI();
manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
}
use of javax.wsdl.Fault in project cxf by apache.
the class WSDLRefValidator method collectValidationPointsForPortTypes.
private void collectValidationPointsForPortTypes() {
for (QName ptName : portTypeRefNames) {
PortType portType = getPortType(ptName);
if (portType == null) {
vResults.addError(new Message("NO_PORTTYPE", LOG, ptName));
continue;
}
XNode vPortTypeNode = getXNode(portType);
for (Operation operation : getOperations(portType).values()) {
XNode vOperationNode = getOperationXNode(vPortTypeNode, operation.getName());
if (operation.getInput() == null) {
vResults.addError(new Message("WRONG_MEP", LOG, operation.getName(), portType.getQName()));
continue;
}
javax.wsdl.Message inMsg = operation.getInput().getMessage();
if (inMsg == null) {
addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no input message");
} else {
XNode vInMsgNode = getXNode(inMsg);
vInMsgNode.setFailurePoint(getInputXNode(vOperationNode, operation.getInput().getName()));
vNodes.add(vInMsgNode);
messageRefNames.add(inMsg.getQName());
}
if (operation.getOutput() != null) {
javax.wsdl.Message outMsg = operation.getOutput().getMessage();
if (outMsg == null) {
addWarning("Operation " + operation.getName() + " in PortType: " + portType.getQName() + " has no output message");
} else {
XNode vOutMsgNode = getXNode(outMsg);
vOutMsgNode.setFailurePoint(getOutputXNode(vOperationNode, operation.getOutput().getName()));
vNodes.add(vOutMsgNode);
messageRefNames.add(outMsg.getQName());
}
}
for (Iterator<?> iter = operation.getFaults().values().iterator(); iter.hasNext(); ) {
Fault fault = (Fault) iter.next();
javax.wsdl.Message faultMsg = fault.getMessage();
XNode vFaultMsgNode = getXNode(faultMsg);
vFaultMsgNode.setFailurePoint(getFaultXNode(vOperationNode, fault.getName()));
vNodes.add(vFaultMsgNode);
messageRefNames.add(faultMsg.getQName());
}
}
}
}
Aggregations