axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Flores, Raul" <>
Subject RE: non-stub doc-lit client
Date Thu, 07 Oct 2004 00:15:37 GMT
I don't think you can use client.Call for a doc/lit service.
Build client stubs from wsdl and then use the XXXLocator and getXXXPort
to obtain a handle to the service.

Locator l = new Locator();
PortType pt = locator.getPortType();


-----Original Message-----
From: Jeff Greif [] 
Sent: Wednesday, October 06, 2004 6:49 PM
Subject: non-stub doc-lit client

When a wsdl operation is defined to be doc/lit, the
setOperation() methods seem to make unexpected assumptions about the
form of
the argument parameters, both in number and type.   I tested this in
axis-1_2RC1 using the client program pasted below.  Clearly I must be
missing something.  Is the behavior below by design?

Suppose I have a wsdl defined to have

   <schema ...
     <element name="op" >
                 <element name="s1" type="xsd:string"/>
                  <element name="s2" type="xsd:int"/>

     <element name="opReturn" ...>

<message name="opRequest">
   <part name="part" element="tns:op"/>

<message name="opResponse">
   <part name="ret" element="tns:opReturn"/>

   <operation name="op">
      <input message="tns:opRequest"/>
      <output message="tns:opResponse"/>

and the binding specifies a doc/lit operation.

If I understand correctly, a doc/lit operation such as that above
defined suitably for compatibility with the WS-I Basic Profile should
take a single parameter which is an element or document and return an
Element or Document. I assumed, incorrectly, it seems, that a single
argument should be passed in the client.

I try to pass this argument to Call.invoke in the form of an
but these things go wrong:
   1.  The client program requires two objects in the parameter array
passed to invoke.
   2.  If I supply the first one as above, and a null second one, the
soap body contains: <Body>

That is,  it is assumed that the constituents of the operation's input
doc part will be provided as separate parameters, rather than as a
single document.

The example below is self-contained and should depend only on the jars
in the Axis build.

---------------------- ----------------- import; import; import;

import org.w3c.dom.*;
import org.xml.sax.*;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

import javax.xml.parsers.*;
// import javax.xml.transform.*;
// import*;
// import javax.xml.transform.dom.*;

// import org.apache.axis.encoding.ser.ElementSerializerFactory;
// import org.apache.axis.encoding.ser.ElementDeserializerFactory;
// import org.apache.axis.encoding.ser.ElementDeserializer;

public class TestClientDocLit
//     static TransformerFactory tf = TransformerFactory.newInstance();

   public static void main(String [] args) {
       try {
           String ns = "";

           QName serviceName
               = new QName(ns, "WolframSearchService");
           QName operationName = new QName(ns, "WolframQuickSearch");
           QName portName
               = new QName(ns, "WolframSearchPort");
           QName returnQName = new QName(ns,
           String endpoint =


           Service service
               = new
h.wsdl", serviceName);

           Call call
               = (Call) service.createCall(portName,

           String testStr
               = "<WolframQuickSearch xmlns='" + ns
               + "'><text>definite

           Document d = null;

           try {
               DocumentBuilderFactory dbf =
               DocumentBuilder db = dbf.newDocumentBuilder();
               d = db.parse(new InputSource(new StringReader(testStr)));
           } catch (Exception e) {
               System.err.println("Failed to parse test doc " + e);

           Element ret = (Element) call.invoke(operationName, new
Object[] {
               d.getDocumentElement(), null  // have to add ", null"
here to get invocation

//            System.out.println("Sent:");
//            serialize(d);
//            if (ret != null) {
//                System.out.println("Received:");
//                serialize(ret);
//            } else {
//                System.err.println("Null response.");
//            }

       } catch (Exception e) {

//     static void serialize(Document d) {
//         serialize(d.getDocumentElement());
//     }

//     static void serialize(Element e) {
//         try {
//             tf.newTransformer().transform(new DOMSource(e), new
//         } catch (Exception x) {
//             System.err.println("Failed to serialize " + x);
//         }

//     }

View raw message