Jos van den Oever wrote:

On Friday 17 June 2005 09:11, Aleksander Slominski wrote:
you are welcome to take a look on XSUL2 that has this and many other
improvements - in particular WSIFMessage is XmlElement and XML-Java
mapping is optional layer - XmlBeans looked like the most complete XML
Schema data binding so it is supported and there is simple XWSDL code
generator that is SOAP toolkit independent:
http://www.extreme.indiana.edu/xgws/xsul/guide/

I took a look at http://www.extreme.indiana.edu/viewcvs/~checkout~/xsul/sample_decoder/src/decoder/client/DecoderClient.java but it seems to require a stub class. Since I want to write a client to invoke _any_ webservice, i don't see how i can use this because I cannot generate a stub in advance.
both stub and DII API (Dynamic Invocation Interface) are supported and DII is just WSIF-like, see:
http://www.extreme.indiana.edu/xgws/xsul/guide/#client.dii

Would it be possible to do something like this:

WSIFClient wsc = WSIFRuntime.newClient(wsdlLoc);
WSIFRuntime is meant for dynamic stubs you can use WSIF API direclty. for example see DII client that takes WSDL, operaiton, and parameters as strings from command line:

http://www.extreme.indiana.edu/viewcvs/~checkout~/xsul/java/modules/xwsif_dynamic_invoker/xsul/dii/XsulDynamicInvoker.java

// find the default bound operation
Operation operation = wsc.findOperation(operName);
if (operation == null) {
        System.out.println("Operation "+operName+" is not available.");
}
operation.addInput(inputName, inputNode);
WsdlDefinitions def = WsdlResolver.getInstance().loadWsdl(base, new URI(wsdlLoc)); WSIFServiceFactory wsf = WSIFServiceFactory.newInstance();
       WSIFService serv = wsf.getService(def);
WSIFPort port = serv.getPort(portName); WSIFOperation op = port.createOperation(opName);
       WSIFMessage in = op.createInputMessage();

and then set input to actual XML, for example:

XmlElement sarray = builder.parseFragmentFromReader(new StringReader("<foo>... some xml content ... </foo>"));
       in.setObjectPart("foo",sarray);


operation.call();
       boolean succes = op.executeRequestResponseOperation(in, out, fault);
       if(succes) {
           System.out.println("received response "+out);
       } else {
           System.err.println("received fault "+fault);
       }

for (Part p : operation.getOutput()) {
        System.out.println(p.name()+": "+p.xmlNode());
}
another sample has this in more details:
http://www.extreme.indiana.edu/viewcvs/~checkout~/xsul/java/samples/xsul_sample_google/Client.java
where it extracts data from XML output (XPath could be used too as XPP3 supports Jaxen API)

      boolean succes = op.executeRequestResponseOperation(in, out, fault);
       if(succes) {
           //System.out.println("received response "+out);
           XmlElement response = (XmlElement) out;
           // return/resultElements
           XmlElement resultElements = response
               .requiredElement(null, "return")
               .requiredElement(null, "resultElements");
           // print URLs of all */URL/text()
           int count = 1;
           for (Iterator i = resultElements.elements(null, null).iterator(); 
i.hasNext(); ) {
               XmlElement item = (XmlElement) i.next();
               System.out.println((count++)+". "+item
                                      .element(null, "URL")
                                      .requiredTextContent());
           }
       } else {
           System.out.println("received fault "+fault);
       }


Also I don't want to do any XML Schema validation initially. I just want to read a WSDL, find a bound operation, specify it's input as XML nodes, call the operation and process the ouput and faults.
that was motivation behind XSUL1 and my work on adding WSIF APIs in XSUL2: to make all this possible and clearly define layers and dependencies between modules.

The input parts need to be specified as nodes, not elements, because e.g. a part of type xs:string is not an element.
i only support WSDL doc/literal and no rpc/encoding.

Which module of xsul2 should I obtain to write only such a client?
check build.xml and add a target to compile of modules that are necessary to build xwsif*client,xwsdl, and required soap* client modules.

alek

--
The best way to predict the future is to invent it - Alan Kay

Reply via email to