List of usage examples for javax.xml.soap SOAPElement getElementName
public Name getElementName();
From source file:it.cnr.icar.eric.server.cms.ContentCatalogingServiceImpl.java
public ServiceOutput invoke(ServerRequestContext context, ServiceInput input, ServiceType service, InvocationController invocationController, UserType user) throws RegistryException { if (log.isDebugEnabled()) { log.debug("ContentCatalogingServiceImpl.invoke():: input: " + input + "; Service: " + service + "; invocationController: " + invocationController + "; user: " + user); }// w w w.ja v a 2s . c o m String accessURI = selectAccessURI(service); SOAPElement responseElement; Object responseObj; ServiceOutput output = new ServiceOutput(); ServerRequestContext outputContext = null; try { outputContext = context; //new RequestContext(null); CatalogContentRequest ebCatalogContentRequest = bu.cmsFac.createCatalogContentRequest(); RegistryObjectListType ebRegistryObjectListType = bu.rimFac.createRegistryObjectListType(); // create element JAXBElement<RegistryObjectType> ebRegistryObject = bu.rimFac .createRegistryObject(input.getRegistryObject()); // add element ebRegistryObjectListType.getIdentifiable().add(ebRegistryObject); ebCatalogContentRequest.setOriginalContent(ebRegistryObjectListType); System.err.println("InvocationControlFile class: " + qm.getRegistryObject(outputContext, invocationController.getEoId()).getClass().getName()); ExtrinsicObjectType icfEOT = bu.rimFac.createExtrinsicObjectType(); icfEOT.setId(invocationController.getEoId()); ebCatalogContentRequest.getInvocationControlFile().add(icfEOT); if (log.isDebugEnabled()) { log.debug("\n\nOriginalContent:"); printNodeToConsole(bu.getSOAPElementFromBindingObject(input.getRegistryObject())); } Collection<AttachmentPart> attachments = new ArrayList<AttachmentPart>(); // RepositoryItem for input to be cataloged. attachments.add(getRepositoryItemAsAttachmentPart(input.getRegistryObject().getId())); // RepositoryItem for InvocationControlFile. attachments.add(getRepositoryItemAsAttachmentPart(invocationController.getEoId())); ContentCatalogingServiceSOAPService soapService = new ContentCatalogingServiceSOAPService_Impl(); ContentCatalogingServicePortType_Stub stub = (ContentCatalogingServicePortType_Stub) soapService .getContentCatalogingServicePort(); stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, accessURI); stub._setProperty(com.sun.xml.rpc.client.StubPropertyConstants.SET_ATTACHMENT_PROPERTY, attachments); responseElement = stub.catalogContent(bu.getSOAPElementFromBindingObject(ebCatalogContentRequest)); responseObj = bu.getBindingObjectFromSOAPElement(responseElement); if (!(responseObj instanceof CatalogContentResponse)) { throw new RegistryException(ServerResourceBundle.getInstance().getString( "message.WrongResponseReceivedFromCatalogingService", new Object[] { responseElement.getElementName().getQualifiedName() })); } CatalogContentResponse ebCatalogContentResponse = (CatalogContentResponse) responseObj; String status = ebCatalogContentResponse.getStatus(); if (log.isDebugEnabled()) { log.debug("Status: " + status); } RegistryObjectListType catalogedMetadata = ebCatalogContentResponse.getCatalogedContent(); // TODO: User should refer to "Service object for the // Content Management Service that generated the // Cataloged Content." outputContext.setUser(user); bu.getObjectRefsAndRegistryObjects(catalogedMetadata, outputContext.getTopLevelRegistryObjectTypeMap(), outputContext.getObjectRefTypeMap()); outputContext.getRepositoryItemsMap().putAll(getRepositoryItems(stub)); output.setOutput(outputContext); output.setErrorList(ebCatalogContentResponse.getRegistryErrorList()); } catch (Exception e) { e.printStackTrace(); if (outputContext != context) { outputContext.rollback(); } throw new RegistryException(e); } if (outputContext != context) { outputContext.commit(); } return output; }
From source file:org.apache.axis.handlers.HandlerChainImpl.java
public ArrayList getMessageInfo(SOAPMessage message) { ArrayList list = new ArrayList(); try {//from ww w. j a v a2 s.c o m if (message == null || message.getSOAPPart() == null) return list; SOAPEnvelope env = message.getSOAPPart().getEnvelope(); SOAPBody body = env.getBody(); Iterator it = body.getChildElements(); SOAPElement operation = (SOAPElement) it.next(); list.add(operation.getElementName().toString()); for (Iterator i = operation.getChildElements(); i.hasNext();) { SOAPElement elt = (SOAPElement) i.next(); list.add(elt.getElementName().toString()); } } catch (Exception e) { log.debug("Exception in getMessageInfo : ", e); } return list; }
From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java
/** * Execute query/*ww w . jav a2 s.c om*/ * * @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(); mh.setHeader("SOAPAction", XMLABaseComponent.EXECUTE_ACTION); //$NON-NLS-1$ SOAPPart soapPart = msg.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.setEncodingStyle(XMLABaseComponent.ENCODING_STYLE); SOAPBody body = envelope.getBody(); Name nEx = envelope.createName("Execute", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$//$NON-NLS-2$ 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> Name nCom = envelope.createName("Command", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$ //$NON-NLS-2$ SOAPElement eCommand = eEx.addChildElement(nCom); Name nSta = envelope.createName("Statement", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$ //$NON-NLS-2$ 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(); paraList.put("DataSourceInfo", dataSource); //$NON-NLS-1$ paraList.put("Catalog", catalog); //$NON-NLS-1$ 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); //$NON-NLS-1$ //$NON-NLS-2$ msg.saveChanges(); debug("Request for Execute"); //$NON-NLS-1$ logSoapMsg(msg); // run the call reply = connection.call(msg, url); debug("Reply from Execute"); //$NON-NLS-1$ logSoapMsg(reply); // error check errorCheck(reply); // process the reply SOAPElement eRoot = findExecRoot(reply); // for each axis, get the positions (tuples) Name name = envelope.createName("Axes", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$ //$NON-NLS-2$ SOAPElement eAxes = selectSingleNode(eRoot, name); if (eAxes == null) { throw new XMLAException("Excecute result has no Axes element"); //$NON-NLS-1$ } name = envelope.createName("Axis", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$ //$NON-NLS-2$ Iterator itAxis = eAxes.getChildElements(name); AxisLoop: for (int iOrdinal = 0; itAxis.hasNext();) { SOAPElement eAxis = (SOAPElement) itAxis.next(); name = envelope.createName("name"); //$NON-NLS-1$ String axisName = eAxis.getAttributeValue(name); int axisOrdinal; if (axisName.equals("SlicerAxis")) { //$NON-NLS-1$ continue; } else { axisOrdinal = iOrdinal++; } name = envelope.createName("Tuples", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$ SOAPElement eTuples = selectSingleNode(eAxis, name); if (eTuples == null) { continue AxisLoop; // what else? } name = envelope.createName("Tuple", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$ 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)) { columnCount = getChildCount(envelope, eTuples, "Tuple"); //$NON-NLS-1$ columnHeaders = new Object[getChildCount(envelope, eTuple, "Member")][columnCount]; //$NON-NLS-1$ } else if ((axisOrdinal == XMLABaseComponent.AXIS_ROWS) && (rowHeaders == null)) { rowCount = getChildCount(envelope, eTuples, "Tuple"); //$NON-NLS-1$ rowHeaders = new Object[rowCount][getChildCount(envelope, eTuple, "Member")]; //$NON-NLS-1$ } int index = 0; name = envelope.createName("Member", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$ 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 name = envelope.createName("CellData", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$ SOAPElement eCellData = selectSingleNode(eRoot, name); name = envelope.createName("Cell", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$ Iterator itSoapCell = eCellData.getChildElements(name); while (itSoapCell.hasNext()) { // CellLoop SOAPElement eCell = (SOAPElement) itSoapCell.next(); name = envelope.createName("CellOrdinal", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String cellOrdinal = eCell.getAttributeValue(name); int ordinal = Integer.parseInt(cellOrdinal); name = envelope.createName("Value", "", XMLABaseComponent.MDD_URI); //$NON-NLS-1$//$NON-NLS-2$ 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 error("?", e); //$NON-NLS-1$ } } } }
From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java
/** * retrieve data source properties//ww w .j av a2s. co m * * @return Map of key/value strings * @see DataSourceBrowser */ public Map discoverDS() throws XMLAException { // Microsoft wants restrictions HashMap rHash = new HashMap(); HashMap pHash = new HashMap(); pHash.put("Content", "Data"); //$NON-NLS-1$ //$NON-NLS-2$ 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)) { continue; // bypass text nodes } SOAPElement e = (SOAPElement) o; String name = e.getElementName().getLocalName(); String value = e.getValue(); resultMap.put(name, value); } } }; discover("DISCOVER_DATASOURCES", url, rHash, pHash, rh); //$NON-NLS-1$ debug(Messages.getInstance().getString("XMLABaseComponent.DEBUG_0005_DISCOVER_DATASOURCE_FOUND") + resultMap.size()); //$NON-NLS-1$ return resultMap; }
From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java
/** * Find the Provider type in the DiscoverResponse * * @param n//from w ww . j a va2 s. com * @return * @throws XMLAException * @throws SOAPException */ private int getProviderFromDiscoverResponse(final SOAPEnvelope envelope, final SOAPElement e) throws XMLAException, SOAPException { Name name = e.getElementName(); if (!name.getLocalName().equals("DiscoverResponse")) { //$NON-NLS-1$ throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0018_NOT_A_DISCOVER_RESPONSE") //$NON-NLS-1$ + name.getLocalName()); } // Look for return/root/row/ProviderName SOAPElement walker = getDiscoverReturn(envelope, e); if (walker == null) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0019_NO_RESULT_DISCOVER_RESPONSE")); //$NON-NLS-1$ } walker = getDiscoverRoot(envelope, walker); if (walker == null) { throw new XMLAException(Messages.getInstance() .getString("XMLABaseComponent.ERROR_0020_NO_RESULT_DISCOVER_RETURN_ROOT")); //$NON-NLS-1$ } walker = getDiscoverRow(envelope, walker); if (walker == null) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0021_NO_DISCOVER_RESPONSE_ROW")); //$NON-NLS-1$ } /* * Name nProviderName = envelope.createName("ProviderName", "", ROWS_URI); SOAPElement eProviderName = * selectSingleNode(e, nProviderName); * * if (eProviderName == null) { throw new OlapException("Discover result has no * DiscoverResponse/return/root/row/ProviderName element"); } value = eProviderName.getValue(); */ String value = null; Iterator it = walker.getChildElements(); while (it.hasNext()) { Object o = it.next(); if (!(o instanceof SOAPElement)) { continue; // bypass text nodes } SOAPElement e2 = (SOAPElement) o; String nameString = e2.getElementName().getLocalName(); if (nameString.equals("ProviderName")) { //$NON-NLS-1$ value = e2.getValue(); debug(Messages.getInstance().getString("XMLABaseComponent.DEBUG_0008_FOUND_PROVIDER") + value); //$NON-NLS-1$ break; } } if ((value == null) || (value.trim().length() == 0)) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0022_NO_PROVIDER_NAME_ELEMENT")); //$NON-NLS-1$ } return determineProvider("Provider=" + value); //$NON-NLS-1$ }