use of javax.wsdl.Message in project carbon-business-process by wso2.
the class SOAPUtils method handleSoapHeaderPartDef.
private static void handleSoapHeaderPartDef(org.apache.ode.bpel.iapi.Message odeMessage, Definition wsdl, SOAPHeader header, javax.wsdl.extensions.soap.SOAPHeader headerdef, Message msgType) throws BPELFault {
// Is this header part of the "payload" messsage?
boolean payloadMessageHeader = headerdef.getMessage() == null || headerdef.getMessage().equals(msgType.getQName());
boolean requiredHeader = payloadMessageHeader || (headerdef.getRequired() != null && headerdef.getRequired());
if (requiredHeader && header == null) {
throw new BPELFault("SOAP Header missing required element.");
}
if (header == null) {
return;
}
Message hdrMsg = wsdl.getMessage(headerdef.getMessage());
if (hdrMsg == null) {
return;
}
Part p = hdrMsg.getPart(headerdef.getPart());
if (p == null || p.getElementName() == null) {
return;
}
OMElement headerEl = header.getFirstChildWithName(p.getElementName());
if (requiredHeader && headerEl == null) {
throw new BPELFault("SOAP Header missing required element: " + p.getElementName());
}
if (headerEl == null) {
return;
}
odeMessage.setHeaderPart(p.getName(), OMUtils.toDOM(headerEl));
}
use of javax.wsdl.Message in project carbon-business-process by wso2.
the class SOAPUtils method handleSOAPHeaderElementsInBindingOperation.
@SuppressWarnings("unchecked")
private static void handleSOAPHeaderElementsInBindingOperation(SOAPEnvelope soapEnvelope, SOAPFactory soapFactory, org.apache.ode.bpel.iapi.Message messageFromOde, Operation wsdlOperation, final javax.wsdl.extensions.soap.SOAPHeader soapHeaderElementDefinition) throws BPELFault {
Map<String, Node> headerParts = messageFromOde.getHeaderParts();
Message responseMessageDefinition = wsdlOperation.getOutput() != null ? wsdlOperation.getOutput().getMessage() : null;
// If there isn't a message attribute in header element definition or if the
// message attribute value is equal to the response message QName, then this
// header element is part of the actual payload.
// Refer SOAP Binding specification at http://www.w3.org/TR/wsdl#_soap-b.
final boolean isHeaderElementAPartOfPayload = soapHeaderElementDefinition.getMessage() == null || ((wsdlOperation.getStyle() != OperationType.ONE_WAY) && soapHeaderElementDefinition.getMessage().equals(responseMessageDefinition.getQName()));
if (soapHeaderElementDefinition.getPart() == null) {
// Part information not found. Ignoring this header definition.
return;
}
if (isHeaderElementAPartOfPayload && (responseMessageDefinition != null && responseMessageDefinition.getPart(soapHeaderElementDefinition.getPart()) == null)) {
// we should throw a exception.
throw new BPELFault("SOAP Header Element Definition refer unknown part.");
}
Element partElement = null;
if (headerParts.size() > 0 && isHeaderElementAPartOfPayload) {
try {
partElement = (Element) headerParts.get(soapHeaderElementDefinition.getPart());
} catch (ClassCastException e) {
throw new BPELFault("SOAP Header must be a DOM Element.", e);
}
}
// message payload. This is because, some headers will provided by SOAP engine.
if (partElement == null && isHeaderElementAPartOfPayload) {
if (messageFromOde.getPart(soapHeaderElementDefinition.getPart()) != null) {
partElement = messageFromOde.getPart(soapHeaderElementDefinition.getPart());
} else {
throw new BPELFault("Missing Required part in response message.");
}
}
// and can be found and extracted from the odeMessage object
if (partElement == null && messageFromOde.getParts().size() > 0 && !isHeaderElementAPartOfPayload) {
try {
partElement = (Element) messageFromOde.getPart(soapHeaderElementDefinition.getPart());
} catch (ClassCastException e) {
throw new BPELFault("Soap header must be an element" + messageFromOde.getPart(soapHeaderElementDefinition.getPart()));
}
}
// just ignore this case.
if (partElement == null) {
return;
}
org.apache.axiom.soap.SOAPHeader soapHeader = soapEnvelope.getHeader();
if (soapHeader == null) {
soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
}
OMElement omPart = OMUtils.toOM(partElement, soapFactory);
for (Iterator<OMNode> i = omPart.getChildren(); i.hasNext(); ) {
soapHeader.addChild(i.next());
}
}
use of javax.wsdl.Message in project carbon-business-process by wso2.
the class WSDLAwareSOAPProcessor method handleSoapHeaderPartDef.
private void handleSoapHeaderPartDef(WSDLAwareMessage message, SOAPHeader headerDef, Message msgType, org.apache.axiom.soap.SOAPHeader soapHeader) throws AxisFault {
boolean payloadMessageHeader = headerDef.getMessage() == null || headerDef.getMessage().equals(msgType.getQName());
boolean requiredHeader = payloadMessageHeader || (headerDef.getRequired() != null && headerDef.getRequired());
if (requiredHeader && soapHeader == null) {
throw new AxisFault("Missing required SOAP header element.");
}
if (soapHeader == null) {
return;
}
Message headerMsg = wsdlDef.getMessage(headerDef.getMessage());
if (headerMsg == null) {
return;
}
Part p = headerMsg.getPart(headerDef.getPart());
if (p == null || p.getElementName() == null) {
return;
}
OMElement headerEl = soapHeader.getFirstChildWithName(p.getElementName());
if (requiredHeader && headerEl == null) {
throw new AxisFault("Missing required SOAP header element.");
}
if (headerEl == null) {
return;
}
message.addHeaderPart(p.getName(), headerEl);
}
use of javax.wsdl.Message in project teiid by teiid.
the class WSDLMetadataProcessor method buildSoapOperation.
private void buildSoapOperation(MetadataFactory mf, BindingOperation bindingOperation) {
Operation operation = bindingOperation.getOperation();
// add input
String inputXML = null;
Input input = operation.getInput();
if (input != null) {
Message message = input.getMessage();
if (message != null) {
inputXML = message.getQName().getLocalPart();
}
}
// add output
String outXML = null;
Output output = operation.getOutput();
if (output != null) {
Message message = output.getMessage();
if (message != null) {
outXML = message.getQName().getLocalPart();
}
}
// $NON-NLS-1$
ExtensibilityElement operationExtension = getExtensibilityElement(bindingOperation.getExtensibilityElements(), "operation");
if (!(operationExtension instanceof SOAPOperation) && !(operationExtension instanceof SOAP12Operation)) {
return;
}
if (operationExtension instanceof SOAPOperation) {
// soap:operation
SOAPOperation soapOperation = (SOAPOperation) operationExtension;
String style = soapOperation.getStyle();
if (style.equalsIgnoreCase("rpc")) {
// $NON-NLS-1$
LogManager.logInfo(LogConstants.CTX_CONNECTOR, WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15004, operation.getName()));
return;
}
} else if (operationExtension instanceof SOAP12Operation) {
// soap:operation
SOAP12Operation soapOperation = (SOAP12Operation) operationExtension;
String style = soapOperation.getStyle();
if (style.equalsIgnoreCase("rpc")) {
// $NON-NLS-1$
LogManager.logInfo(LogConstants.CTX_CONNECTOR, WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15004, operation.getName()));
return;
}
}
Procedure procedure = mf.addProcedure(operation.getName());
procedure.setVirtual(false);
procedure.setNameInSource(operation.getName());
mf.addProcedureParameter(inputXML, TypeFacility.RUNTIME_NAMES.XML, Type.In, procedure);
// $NON-NLS-1$
ProcedureParameter param = mf.addProcedureParameter("stream", TypeFacility.RUNTIME_NAMES.BOOLEAN, Type.In, procedure);
// $NON-NLS-1$
param.setAnnotation("If the result should be streamed.");
param.setNullType(NullType.Nullable);
// $NON-NLS-1$
param.setDefaultValue("false");
mf.addProcedureParameter(outXML, TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, procedure);
}
use of javax.wsdl.Message 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);
}
}
}
Aggregations