Jacques-Olivier Goussard wrote:
there is nothing preventing you from reading XML directly (to DOM etc) without XmlBeansThanks Alek, I'll take a look to all of this. If you may, this seems however overkill for what most users are asking for it seems, as most are happy manipulating XML. (and later using XmlBeans or other databinding), compare client with XmlBeans mapping conveniently available (2) and the same client that uses WSIF API to construct XML directly (1): (1) http://www.extreme.indiana.edu/viewcvs/~checkout~/xsul/sample_decoder/src/decoder/client/LightweightDecoderClient.java LightweightDecoderStub stub = (LightweightDecoderStub) WSIFRuntime.newClient(wsdlLoc)
//.addHandler(new PasswordInvokerHandler("password-invoker"))
.generateDynamicStub(LightweightDecoderStub.class);
XmlElement in = builder.newFragment(NS, "runDecoder");
in.addElement("Topic").addChild(args[1]);
in.addElement("InputFile").addChild(args[2]);
in.addElement("OutputDirectory").addChild(args[3]);
XmlElement el = builder.parseFragmentFromReader(
new StringReader("<StringArr><item>Arg1</item><item>Arg2</item></StringArr>"));
in.addElement(el);
String s = Util.safeXmlToString((XmlContainer)in);
System.out.println("sending message =\n"+s);
XmlElement result = stub.run(in);
System.out.println("result=\n"+Util.safeXmlToString(result));
(2)
http://www.extreme.indiana.edu/viewcvs/~checkout~/xsul/sample_decoder/src/decoder/client/DecoderClient.java WSIFClient wcl = XmlBeansWSIFRuntime.newClient(wsdlLoc);
DecoderPortType stub = (DecoderPortType)wcl.generateDynamicStub(DecoderPortType.class);
DecoderRunInputParamsDocument inputMsg = DecoderRunInputParamsDocument.Factory.newInstance();
DecoderRunInputParamsType params = inputMsg.addNewDecoderRunInputParams();
params.setTopic(args[1]);
params.setCorrelationId(args[2]);
params.setInputFile(args[3]);
params.setOutputDirectory(args[4]);
String[] arr = new String[]{"argA", "argB"};
params.addNewStringArr().setItemArray(arr);
params.setNproc(77); //override default
DecoderRunOutputParamsDocument outputMsg = stub.run(inputMsg);
DecoderRunOutputParamsType result = outputMsg.getDecoderRunOutputParams();
System.out.println("outputUrl="+result.getOutputURL());
however it is difficult if you want to do XSD validation and databinding to WSDL that is known/discovered only *during* runtime - it seems to me simpler to have two groups of clients/services: those created from known (abstract) WSDL and those that need to deal with any WSDL. it depends what you need to do. if you need to implement or access serviceIt seems leaving XML to Java binding (i.e. XmlBean) in the user hands would be enough. described in (abstract) WSDL then it is convenient to generate java interfaces from WSDL:portType/interface and databinding code (XmlBeans) from XSD inside WSDL. then writing client and service implementation is very easy. for dynamic clients i do not see any real need to do actual Java<->XML databinding - such client deals with any WSDL/XSD so even if you do databinding then how users are supposed to use it? using Java reflection? wouldn't it be simpler (and less of leaky abstractions) to have XML Schema introspection and then use XML directly? this is pretty strong assumption - do you assume all services you use are java based and have their WSDLs built by Java introspection? what if you have external services and/or services written in other languages (mapping Java Beans <-> XSD may be very difficult) thanks, alek so if every XML fragment used as input is a valid XSD type instance, you should not get into this problem (?). Of course, this implies you do not use interfaces in the service methods declarations. Or you need metadata on the service to map those to real classes - but not stored in the WSDL then. /jog-----Original Message----- From: Aleksander Slominski [mailto:[EMAIL PROTECTED]] Sent: Friday, May 06, 2005 11:00 AM To: [email protected] Cc: [email protected]; '[email protected]' Subject: [Axis2] mapping XML/XSD <-> Java [Re: Complex types: do the reverse ? Jacques-Olivier Goussard wrote: -- The best way to predict the future is to invent it - Alan Kay |
