Code Comments
Programming Forum and web based access to our favorite programming groups.>>> On 5/29/2007 at 7:46 PM, in message <5c43beF2tm0i9U1@mid.individual.net>, Pete Dashwood<dashwood@removethis.enternet.co.nz> wrote: > "Frank Swarbrick" <Frank.Swarbrick@efirstbank.com> wrote in message > news:465C1C50.6F0F.0085.0@efirstbank.com... > > That isn't exactly what I feel... :-) I feel the need to be able to use > COM > from Java so that the richness of the several thousand COM servers > already > on my machine can be unlocked and used by Java. The SOAP Toolkit is just > ONE > such COM server. > > are > Yes, you COULD do it all with SOAP, yourself (after all, it's just > XML...) > but it is MUCH easier if you invoke the methods of the SOAP COM object, > and > it takes a lot less code). There are no worries with establishing socket > > connections, checking transfers, detecting errors, etc. it is all > provided > by a COM server. Why re-invent the wheel? In a non Windows environment > where > you don't have the SOAP toolkit available, you don't have much option, > other > than to do it yourself. This is partly why SOAP is obsolete and DotNET > services are replacing it; they run across most platforms. > > > Sure. The nearest analogy I can think of quickly is: Why write Assembler > > when you can write COBOL? OK. I guess I'm just not sure what you are doing. Here is the demo client program for the apache SOAP service. Is calling the SOAP COM object from Java simpler than this? package samples.stockquote; import java.io.*; import java.net.*; import java.util.*; import org.apache.soap.*; import org.apache.soap.rpc.*; /** * See README for info. * * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com) */ public class GetQuote { public static void main (String[] args) throws Exception { if (args.length != 2 && (args.length != 3 || !args[0].startsWith ("-"))) { System.err.println ("Usage: java " + GetQuote.class.getName () + " [-encodingStyleURI] SOAP-router-URL symbol"); System.exit (1); } // Process the arguments. int offset = 3 - args.length; String encodingStyleURI = args.length == 3 ? args[0].substring(1) : Constants.NS_URI_SOAP_ENC; URL url = new URL (args[1 - offset]); String symbol = args[2 - offset]; // Build the call. Call call = new Call (); call.setTargetObjectURI ("urn:xmltoday-delayed-quotes"); call.setMethodName ("getQuote"); call.setEncodingStyleURI(encodingStyleURI); Vector params = new Vector (); params.addElement (new Parameter("symbol", String.class, symbol, null)); call.setParams (params); // make the call: note that the action URI is empty because the // XML-SOAP rpc router does not need this. This may change in the // future. Response resp = call.invoke (/* router URL */ url, /* actionURI */ "" ); // Check the response. if (resp.generatedFault ()) { Fault fault = resp.getFault (); System.err.println("Generated fault: " + fault); } else { Parameter result = resp.getReturnValue (); System.out.println (result.getValue ()); } } } Of course if you want to invoke other COM services than I certainly can see the usefulness of that. Frank
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.