/** * Main entry point. Tests a variety of echo methods and reports on their results. * * <p>Arguments are of the form: -h localhost -p 8080 -s /soap/servlet/rpcrouter */ public static void main(String args[]) throws Exception { // set up the call object Options opts = new Options(args); service = new Service(); call = (Call) service.createCall(); call.setTargetEndpointAddress(new URL(opts.getURL())); call.setUseSOAPAction(true); call.setSOAPActionURI("http://www.soapinterop.org/Bid"); // register the PurchaseOrder class QName poqn = new QName("http://www.soapinterop.org/Bid", "PurchaseOrder"); Class cls = PurchaseOrder.class; call.registerTypeMapping(cls, poqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); // register the Address class QName aqn = new QName("http://www.soapinterop.org/Bid", "Address"); cls = Address.class; call.registerTypeMapping(cls, aqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); // register the LineItem class QName liqn = new QName("http://www.soapinterop.org/Bid", "LineItem"); cls = LineItem.class; call.registerTypeMapping(cls, liqn, BeanSerializerFactory.class, BeanDeserializerFactory.class); try { // Default return type based on what we expect call.setOperationName(new QName("http://www.soapinterop.org/Bid", "Buy")); call.addParameter("PO", poqn, ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); LineItem[] li = new LineItem[2]; li[0] = new LineItem("Tricorder", 1, "2500.95"); li[1] = new LineItem("Phasor", 3, "7250.95"); PurchaseOrder po = new PurchaseOrder( "NCC-1701", Calendar.getInstance(), new Address("Sam Ruby", "Home", "Raleigh", "NC", "27676"), new Address("Lou Gerstner", "Work", "Armonk", "NY", "15222"), li); // issue the request String receipt = (String) call.invoke(new Object[] {po}); System.out.println(receipt); } catch (Exception e) { System.out.println("Buy failed: " + e); throw e; } }
public static void main(String args[]) throws Exception { Options opts = new Options(args); // first check if we should print usage if ((opts.isFlagSet('?') > 0) || (opts.isFlagSet('h') > 0)) printUsage(); String username = opts.getUser(); String password = opts.getPassword(); HashMap connectorMap = SimpleJMSListener.createConnectorMap(opts); HashMap cfMap = SimpleJMSListener.createCFMap(opts); String destination = opts.isValueSet('d'); // create the jms listener SimpleJMSListener listener = new SimpleJMSListener(connectorMap, cfMap, destination, username, password, false); listener.start(); args = opts.getRemainingArgs(); if (args == null || args.length == 0) printUsage(); for (int i = 0; i < args.length; i++) { try { Float res = getQuote(args[i], username, password); System.out.println(args[i] + ": " + res); } catch (AxisFault af) { System.out.println(af.dumpToString()); } } // shutdown listener.shutdown(); // close all JMSConnectors whose configuration matches that of the JMS URL // note: this is optional, as all connectors will be closed upon exit JMSTransport.closeMatchingJMSConnectors(sampleJmsUrl, username, password); System.exit(1); }
/** * This method is called when 'Finish' button is pressed in the wizard. We will create an * operation and run it using wizard as execution context. */ public boolean performFinish() { try { Options opts = new Options(new String[0]); opts.setDefaultURL(serverPage.getSelectedServer() + "/services/NMRShiftDB"); Service service = new Service(); Call call = (Call) service.createCall(); call.setOperationName("doSearch"); call.setTargetEndpointAddress(new URL(opts.getURL())); DocumentBuilder builder; builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); SOAPBodyElement[] input = new SOAPBodyElement[1]; Document doc = builder.newDocument(); Element cdataElem; cdataElem = doc.createElementNS("http://www.nmrshiftdb.org/ws/NMRShiftDB/", "doSearch"); Element reqElem; reqElem = doc.createElementNS("http://www.nmrshiftdb.org/ws/NMRShiftDB/", "searchstring"); /*DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Node node = db.parse(new ByteArrayInputStream(new Convertor(true,"").cdkAtomContainerToCMLMolecule(ac).toXML().getBytes()));*/ Node node = DOMConverter.convert( new nu.xom.Document(new Convertor(true, "").cdkAtomContainerToCMLMolecule(ac)), builder.getDOMImplementation()) .getFirstChild(); reqElem.appendChild(doc.importNode(node, true)); Element reqElem2; reqElem2 = doc.createElementNS("http://www.nmrshiftdb.org/ws/NMRShiftDB/", "searchtype"); Node node2; node2 = doc.createTextNode("--"); reqElem2.appendChild(node2); Element reqElem3; reqElem3 = doc.createElementNS("http://www.nmrshiftdb.org/ws/NMRShiftDB/", "searchfield"); Node node3; node3 = doc.createTextNode(NmrshiftdbUtils.replaceSpaces(serverPage.selectedOption())); reqElem3.appendChild(node3); cdataElem.appendChild(reqElem); cdataElem.appendChild(reqElem2); cdataElem.appendChild(reqElem3); input[0] = new SOAPBodyElement(cdataElem); Vector elems = (Vector) call.invoke(input); SOAPBodyElement elem = (SOAPBodyElement) elems.get(0); Element e = elem.getAsDOM(); CMLBuilder cmlbuilder = new CMLBuilder(); CMLElement cmlElement = (CMLElement) cmlbuilder.parseString(XMLUtils.ElementToString(e)); if (cmlElement.getChildCount() > 0) { IFolder folder = NmrshiftdbUtils.createVirtualFolder(); for (int i = 0; i < cmlElement.getChildCount(); i++) { net.bioclipse.specmol.Activator.getDefault() .getJavaSpecmolManager() .saveSpecmol( new JumboSpecmol((CMLCml) cmlElement.getChildCMLElements().get(i)), folder.getFile( ((CMLMolecule) cmlElement .getChildCMLElements() .get(i) .getChildCMLElement("molecule", 0)) .getId() + "." + SpectrumEditor.CML_TYPE)); } } else { MessageDialog.openInformation( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "No results", "No spectra in NMRShiftDB for this structure!"); } } catch (Exception ex) { LogUtils.handleException(ex, logger); } return true; }