use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.
the class SOAP12ServerHandler method handleInbound.
@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
log.info("handleInbound");
ContentType contentType = getContentType(msgContext);
if (contentType != null) {
log.info("contentType=" + contentType);
String startInfo = contentType.getParameter("start-info");
if (!startInfo.equals(SOAPConstants.SOAP_1_2_CONTENT_TYPE)) {
return false;
}
} else {
return false;
}
try {
SOAPEnvelope soapEnvelope = ((SOAPMessageContext) msgContext).getMessage().getSOAPPart().getEnvelope();
String nsURI = soapEnvelope.getNamespaceURI();
log.info("nsURI=" + nsURI);
if (!SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(nsURI)) {
return false;
}
} catch (SOAPException se) {
throw new WebServiceException(se);
}
return true;
}
use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.
the class ProviderMessageTestCase method testProviderDispatch.
@Test
@RunAsClient
public void testProviderDispatch() throws Exception {
Dispatch<SOAPMessage> dispatch = createDispatch("ProviderEndpoint");
SOAPMessage reqMsg = getRequestMessage();
SOAPMessage resMsg = dispatch.invoke(reqMsg);
SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = resEnv.getHeader();
if (soapHeader != null)
soapHeader.detachNode();
assertEquals(DOMUtils.parse(msgString), resEnv);
}
use of javax.xml.soap.SOAPEnvelope in project jbossws-cxf by jbossws.
the class ProviderPayloadTestCase method testProviderMessage.
@Test
@RunAsClient
public void testProviderMessage() throws Exception {
String reqEnvStr = "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" + " <env:Body>" + reqString + "</env:Body>" + "</env:Envelope>";
MessageFactory msgFactory = MessageFactory.newInstance();
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnvStr.getBytes()));
URL epURL = baseURL;
SOAPMessage resMsg = con.call(reqMsg, epURL);
SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = resEnv.getHeader();
if (soapHeader != null)
soapHeader.detachNode();
Node responseBody = DOMUtils.getFirstChildElement(resEnv.getBody());
assertEquals("wrong namespace: " + responseBody.getNamespaceURI(), "http://org.jboss.ws/provider", responseBody.getNamespaceURI());
assertEquals("wrong localPart: " + responseBody.getLocalName(), "somePayload", responseBody.getLocalName());
String responseString = DOMUtils.getTextContent(responseBody);
assertEquals("wrong content: " + responseString, "Hello:Inbound:LogicalSourceHandler:Outbound:LogicalSourceHandler", responseString);
}
use of javax.xml.soap.SOAPEnvelope in project pentaho-platform by pentaho.
the class XMLABaseComponent method discoverDS.
/**
* retrieve data source properties
*
* @return Map of key/value strings
* @see DataSourceBrowser
*/
public Map discoverDS() throws XMLAException {
// Microsoft wants restrictions
HashMap rHash = new HashMap();
HashMap pHash = new HashMap();
// $NON-NLS-1$ //$NON-NLS-2$
pHash.put("Content", "Data");
final Map resultMap = new HashMap();
Rowhandler rh = new Rowhandler() {
public void handleRow(SOAPElement eRow, SOAPEnvelope envelope) {
/*
* <row><DataSourceName>SAP_BW</DataSourceName> <DataSourceDescription>SAP BW Release 3.0A XML f. Analysis
* Service</DataSourceDescription> <URL>http://155.56.49.46:83/SAP/BW/XML/SOAP/XMLA</URL>
* <DataSourceInfo>default</DataSourceInfo> <ProviderName>SAP BW</ProviderName> <ProviderType>MDP</ProviderType>
* <AuthenticationMode>Integrated</AuthenticationMode></row>
*/
Iterator it = eRow.getChildElements();
while (it.hasNext()) {
Object o = it.next();
if (!(o instanceof SOAPElement)) {
// bypass text nodes
continue;
}
SOAPElement e = (SOAPElement) o;
String name = e.getElementName().getLocalName();
String value = e.getValue();
resultMap.put(name, value);
}
}
};
// $NON-NLS-1$
discover("DISCOVER_DATASOURCES", url, rHash, pHash, rh);
debug(Messages.getInstance().getString("XMLABaseComponent.DEBUG_0005_DISCOVER_DATASOURCE_FOUND") + resultMap.size());
return resultMap;
}
use of javax.xml.soap.SOAPEnvelope in project pentaho-platform by pentaho.
the class XMLABaseComponent method executeQuery.
/**
* Execute query
*
* @param query - MDX to be executed
* @param catalog
* @param handler Callback handler
* @throws XMLAException
*/
public boolean executeQuery(final String query, final String catalog) throws XMLAException {
Object[][] columnHeaders = null;
Object[][] rowHeaders = null;
Object[][] data = null;
int columnCount = 0;
int rowCount = 0;
SOAPConnection connection = null;
SOAPMessage reply = null;
try {
connection = scf.createConnection();
SOAPMessage msg = mf.createMessage();
MimeHeaders mh = msg.getMimeHeaders();
// $NON-NLS-1$
mh.setHeader("SOAPAction", XMLABaseComponent.EXECUTE_ACTION);
SOAPPart soapPart = msg.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.setEncodingStyle(XMLABaseComponent.ENCODING_STYLE);
SOAPBody body = envelope.getBody();
// $NON-NLS-1$//$NON-NLS-2$
Name nEx = envelope.createName("Execute", "", XMLABaseComponent.XMLA_URI);
SOAPElement eEx = body.addChildElement(nEx);
eEx.setEncodingStyle(XMLABaseComponent.ENCODING_STYLE);
// add the parameters
// COMMAND parameter
// <Command>
// <Statement>select [Measures].members on Columns from
// Sales</Statement>
// </Command>
// $NON-NLS-1$ //$NON-NLS-2$
Name nCom = envelope.createName("Command", "", XMLABaseComponent.XMLA_URI);
SOAPElement eCommand = eEx.addChildElement(nCom);
// $NON-NLS-1$ //$NON-NLS-2$
Name nSta = envelope.createName("Statement", "", XMLABaseComponent.XMLA_URI);
SOAPElement eStatement = eCommand.addChildElement(nSta);
eStatement.addTextNode(query);
// <Properties>
// <PropertyList>
// <DataSourceInfo>Provider=MSOLAP;Data
// Source=local</DataSourceInfo>
// <Catalog>Foodmart 2000</Catalog>
// <Format>Multidimensional</Format>
// <AxisFormat>TupleFormat</AxisFormat> oder "ClusterFormat"
// </PropertyList>
// </Properties>
Map paraList = new HashMap();
// $NON-NLS-1$
paraList.put("DataSourceInfo", dataSource);
// $NON-NLS-1$
paraList.put("Catalog", catalog);
// $NON-NLS-1$ //$NON-NLS-2$
paraList.put("Format", "Multidimensional");
// $NON-NLS-1$ //$NON-NLS-2$
paraList.put("AxisFormat", "TupleFormat");
// $NON-NLS-1$ //$NON-NLS-2$
addParameterList(envelope, eEx, "Properties", "PropertyList", paraList);
msg.saveChanges();
// $NON-NLS-1$
debug("Request for Execute");
logSoapMsg(msg);
// run the call
reply = connection.call(msg, url);
// $NON-NLS-1$
debug("Reply from Execute");
logSoapMsg(reply);
// error check
errorCheck(reply);
// process the reply
SOAPElement eRoot = findExecRoot(reply);
// for each axis, get the positions (tuples)
// $NON-NLS-1$ //$NON-NLS-2$
Name name = envelope.createName("Axes", "", XMLABaseComponent.MDD_URI);
SOAPElement eAxes = selectSingleNode(eRoot, name);
if (eAxes == null) {
// $NON-NLS-1$
throw new XMLAException("Excecute result has no Axes element");
}
// $NON-NLS-1$ //$NON-NLS-2$
name = envelope.createName("Axis", "", XMLABaseComponent.MDD_URI);
Iterator itAxis = eAxes.getChildElements(name);
AxisLoop: for (int iOrdinal = 0; itAxis.hasNext(); ) {
SOAPElement eAxis = (SOAPElement) itAxis.next();
// $NON-NLS-1$
name = envelope.createName("name");
String axisName = eAxis.getAttributeValue(name);
int axisOrdinal;
if (axisName.equals("SlicerAxis")) {
// $NON-NLS-1$
continue;
} else {
axisOrdinal = iOrdinal++;
}
// $NON-NLS-1$//$NON-NLS-2$
name = envelope.createName("Tuples", "", XMLABaseComponent.MDD_URI);
SOAPElement eTuples = selectSingleNode(eAxis, name);
if (eTuples == null) {
// what else?
continue AxisLoop;
}
// $NON-NLS-1$//$NON-NLS-2$
name = envelope.createName("Tuple", "", XMLABaseComponent.MDD_URI);
Iterator itTuple = eTuples.getChildElements(name);
// loop over tuples
int positionOrdinal = 0;
while (itTuple.hasNext()) {
// TupleLoop
SOAPElement eTuple = (SOAPElement) itTuple.next();
if ((axisOrdinal == XMLABaseComponent.AXIS_COLUMNS) && (columnHeaders == null)) {
// $NON-NLS-1$
columnCount = getChildCount(envelope, eTuples, "Tuple");
// $NON-NLS-1$
columnHeaders = new Object[getChildCount(envelope, eTuple, "Member")][columnCount];
} else if ((axisOrdinal == XMLABaseComponent.AXIS_ROWS) && (rowHeaders == null)) {
// $NON-NLS-1$
rowCount = getChildCount(envelope, eTuples, "Tuple");
// $NON-NLS-1$
rowHeaders = new Object[rowCount][getChildCount(envelope, eTuple, "Member")];
}
int index = 0;
// $NON-NLS-1$//$NON-NLS-2$
name = envelope.createName("Member", "", XMLABaseComponent.MDD_URI);
Iterator itMember = eTuple.getChildElements(name);
while (itMember.hasNext()) {
// MemberLoop
SOAPElement eMem = (SOAPElement) itMember.next();
// loop over children nodes
String caption = null;
Iterator it = eMem.getChildElements();
InnerLoop: while (it.hasNext()) {
Node n = (Node) it.next();
if (!(n instanceof SOAPElement)) {
continue InnerLoop;
}
SOAPElement el = (SOAPElement) n;
String enam = el.getElementName().getLocalName();
if (enam.equals("Caption")) {
// $NON-NLS-1$
caption = el.getValue();
}
}
if (axisOrdinal == XMLABaseComponent.AXIS_COLUMNS) {
columnHeaders[index][positionOrdinal] = caption;
} else if (axisOrdinal == XMLABaseComponent.AXIS_ROWS) {
rowHeaders[positionOrdinal][index] = caption;
}
++index;
}
// MemberLoop
++positionOrdinal;
}
// TupleLoop
}
// AxisLoop
data = new Object[rowCount][columnCount];
// loop over cells in result set
// $NON-NLS-1$//$NON-NLS-2$
name = envelope.createName("CellData", "", XMLABaseComponent.MDD_URI);
SOAPElement eCellData = selectSingleNode(eRoot, name);
// $NON-NLS-1$//$NON-NLS-2$
name = envelope.createName("Cell", "", XMLABaseComponent.MDD_URI);
Iterator itSoapCell = eCellData.getChildElements(name);
while (itSoapCell.hasNext()) {
// CellLoop
SOAPElement eCell = (SOAPElement) itSoapCell.next();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
name = envelope.createName("CellOrdinal", "", "");
String cellOrdinal = eCell.getAttributeValue(name);
int ordinal = Integer.parseInt(cellOrdinal);
// $NON-NLS-1$//$NON-NLS-2$
name = envelope.createName("Value", "", XMLABaseComponent.MDD_URI);
Object value = selectSingleNode(eCell, name).getValue();
int rowLoc = ordinal / columnCount;
int columnLoc = ordinal % columnCount;
data[rowLoc][columnLoc] = value;
}
// CellLoop
MemoryResultSet resultSet = new MemoryResultSet();
MemoryMetaData metaData = new MemoryMetaData(columnHeaders, rowHeaders);
resultSet.setMetaData(metaData);
for (Object[] element : data) {
resultSet.addRow(element);
}
rSet = resultSet;
if (resultSet != null) {
if (getResultOutputName() != null) {
setOutputValue(getResultOutputName(), resultSet);
}
return true;
}
return false;
} catch (SOAPException se) {
throw new XMLAException(se);
} finally {
if (connection != null) {
try {
connection.close();
} catch (SOAPException e) {
// log and ignore
// $NON-NLS-1$
error("?", e);
}
}
}
}
Aggregations