public void testEchoXMLSync() throws Exception { for (int i = 0; i < 10; i++) { OMElement payload = createPayload(); Options clientOptions = new Options(); clientOptions.setTo(targetEPR); clientOptions.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP); clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null); ServiceClient sender = new ServiceClient(configContext, null); sender.setOptions(clientOptions); OMElement result = sender.sendReceive(payload); OMElement data = (OMElement) result.getFirstOMChild(); compareWithCreatedOMText(data.getText()); log.info("" + i); UtilServer.unDeployClientService(); } }
/** * Performing the searching operation for the given Geo Query criteria. * * @param twitter * @param query * @return * @throws XMLStreamException * @throws TwitterException * @throws JSONException * @throws IOException */ private OMElement performSearchMessages(List<User> users) throws XMLStreamException, TwitterException, JSONException, IOException { OMElement resultElement = AXIOMUtil.stringToOM("<jsonObject><followers/></jsonObject>"); OMElement childElment = resultElement.getFirstElement(); for (User user : users) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("{ \"follower\" : "); String json = DataObjectFactory.getRawJSON(user); stringBuilder.append(json); stringBuilder.append("} "); OMElement element = super.parseJsonToXml(stringBuilder.toString()); childElment.addChild(element.getFirstOMChild()); } if (users.size() == 0) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("{ \"follower\" : {}"); stringBuilder.append("} "); OMElement element = super.parseJsonToXml(stringBuilder.toString()); resultElement.addChild(element); } return resultElement; }
public static Entry createEntry(OMElement elem, Properties properties) { String customFactory = SynapsePropertiesLoader.getPropertyValue("synapse.entry.factory", ""); if (customFactory != null && !"".equals(customFactory)) { try { Class c = Class.forName(customFactory); Object o = c.newInstance(); if (o instanceof IEntryFactory) { return ((IEntryFactory) o).createEntry(elem); } } catch (ClassNotFoundException e) { handleException( "Class specified by the synapse.entry.factory " + "synapse property not found: " + customFactory, e); } catch (InstantiationException e) { handleException( "Class specified by the synapse.entry.factory " + "synapse property cannot be instantiated: " + customFactory, e); } catch (IllegalAccessException e) { handleException( "Class specified by the synapse.entry.factory " + "synapse property cannot be accessed: " + customFactory, e); } } OMAttribute key = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key")); if (key == null) { handleException("The 'key' attribute is required for a local registry entry"); return null; } else { Entry entry = new Entry(key.getAttributeValue()); OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q); if (descriptionElem != null) { entry.setDescription(descriptionElem.getText()); descriptionElem.detach(); } String src = elem.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "src")); // if a src attribute is present, this is a URL source resource, // it would now be loaded from the URL source, as all static properties // are initialized at startup if (src != null) { try { entry.setSrc(new URL(src.trim())); entry.setType(Entry.URL_SRC); entry.setValue(SynapseConfigUtils.getObject(entry.getSrc(), properties)); } catch (MalformedURLException e) { handleException("The entry with key : " + key + " refers to an invalid URL"); } } else { OMNode nodeValue = elem.getFirstOMChild(); OMElement elemValue = elem.getFirstElement(); if (elemValue != null) { entry.setType(Entry.INLINE_XML); entry.setValue(elemValue); } else if (nodeValue != null && nodeValue instanceof OMText) { entry.setType(Entry.INLINE_TEXT); entry.setValue(elem.getText().trim()); } } return entry; } }