1.4. Dynamic Invocation Interface (DII) with JAX-RPC (RPC/encoded and document/literal in section 1.4.5)

You will find here some client using the DII technique. Our first DII client will be very simple and you will find several others on the internet. Progressively we will test more advanced DII client, like remote procedure returning an array of simple type or (array of) object. There we will need a regular use of wscompile tool.

I mention in the title of each section if the example is for a rpc/encoded or document/literal WSDL web service.

1.4.1. Reading light sensor using Dynamic Invocation Interface (rpc/encoded)

By using DII (Dynamic Invocation Interface) you do not need a tool like WSDL2Java nor wscompile, if you consume a remote procedure returning only simple type and only for rpc/encoded, but your code will not be so short. And if you are dealing with complex type, you have to use another tool: wscompile

But find a template of our simple example first, so the client (ClientDII class) will just comport one file: ClientDII.java as we do not need anymore the class types generated by WSDL2Java for this method returning a simple type (int readLSpercent(int int_1)).

NoteNote
 

The code below is for my rpc/encoded web service (real dii without the use of any tools) and you can use it as a template for your own use. You can also test my document/literal operation style web service, go to the Section called DII client for document/literal operation style.

Example 1-6. Reading light sensor with DII: ClientDII.java

package diiclient;

import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.encoding.XMLType;
import javax.xml.rpc.ParameterMode;

public class ClientDII
{
  public static void main(String[] args) {
    try {

      // create the Service client object
      // using the wsdl and his service name
      QName serviceName = new QName(
	"http://www.pascalbotte.be/rcx-ws-rpc/rcx?WSDL",
	"MyRcxService");
      ServiceFactory factory = ServiceFactory.newInstance();
      Service service = factory.createService(serviceName);
				
      // Call object
      Call call = service.createCall();	

      // operation name
      QName operationName = new QName(
        "http://phonedirlux.homeip.net/wsdl", "readLSpercent");
      call.setOperationName(operationName);
								  
      // input parameter
      call.addParameter(
	"int_1",             // parameter name
	XMLType.XSD_INT, // parameter XML type QName
	int.class,       // parameter Java type class
	ParameterMode.IN);  // parameter mode
	
      // setting return type
      call.setReturnType(XMLType.XSD_INT);

      // specify the RPC-style operation.
      call.setProperty(Call.OPERATION_STYLE_PROPERTY,
        "rpc");
      // and the encoding style
      call.setProperty(
	Call.ENCODINGSTYLE_URI_PROPERTY,
	"http://schemas.xmlsoap.org/soap/encoding/");
							   
      // the target endpoint
      call.setTargetEndpointAddress(
	"http://www.pascalbotte.be/rcx-ws/rcx");
   
      // Invoke the method readLSpercent
      Object[] myArgs = {new Integer(1)};
      Object lsVal =  call.invoke(myArgs);
				  
      System.out.println("Light sensor value:  " +  lsVal.toString());
    }
    catch(Throwable th) {
      th.printStackTrace();
    }
  }
}

So the code is not so short isn't it? But the advantage is a code not dependant of any tool. To execute your client just type:

[your_prompt]$ java diiclient.ClientDII

Like usually, you should be able to read the light sensor value on my RCX. Now let's see how to consume a remote procedure returning an array of int (like the remote procedure collInt()) with the DII technique.

1.4.2. Consume a remote procedure returning an array of simple type (rpc/encoded)

Here we will just need the technique using the registering of our int[] type, to consume the remote procedure collInt(). I rewrited completely the client allowing to add easily portion of code to demo the other remote procedure also returning complex types.

Example 1-7. DII client to consume an array of simple type (int[])

 
package diiclient;

import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.encoding.XMLType;
import javax.xml.rpc.ParameterMode;

import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import com.sun.xml.rpc.encoding.soap.SOAPConstants;
import com.sun.xml.rpc.encoding.CombinedSerializer;
import com.sun.xml.rpc.encoding.ReferenceableSerializerImpl;
import javax.xml.rpc.encoding.SerializerFactory;
import javax.xml.rpc.encoding.DeserializerFactory;
import com.sun.xml.rpc.encoding.SingletonSerializerFactory;
import com.sun.xml.rpc.encoding.SingletonDeserializerFactory;
import com.sun.xml.rpc.encoding.SimpleTypeSerializer;
import com.sun.xml.rpc.encoding.SimpleTypeArraySerializer;
import com.sun.xml.rpc.encoding.simpletype.XSDIntEncoder;

public class RcxClient implements com.sun.xml.rpc.wsdl.document.schema.SchemaConstants,
com.sun.xml.rpc.encoding.SerializerConstants
{
	
  public TypeMapping typeMapping = null;

  public Service service = null;
  public QName intArrayTypeQname = null;
	
  public static void main(String[] args) {
    RcxClient RcxClientObj = new RcxClient();
    RcxClientObj.myInit();
    RcxClientObj.callCollInt();

  }
		
  public void callCollInt( ) {
    try
    {
      //Create the Call object using Service
      Call call = service.createCall();
				
      QName operationName = new QName(
	"http://phonedirlux.homeip.net/wsdl",
	"collInt");
      call.setOperationName(operationName);
												  
      // The return
      call.setReturnType(intArrayTypeQname);
	
      // The operation is an RPC-style operation.
      call.setProperty(Call.OPERATION_STYLE_PROPERTY,"rpc");
	
      // The encoding style property value comes from the
      // binding's operation's input clauses encodingStyle
      // attribute.
      call.setProperty(
	Call.ENCODINGSTYLE_URI_PROPERTY,
	"http://schemas.xmlsoap.org/soap/encoding/");

      // The target endpoint
      call.setTargetEndpointAddress("http://www.pascalbotte.be/rcx-ws-rpc/rcx");
					   
      // Invoke the remote procedure collInt()
      int[] lsVal =  (int[])call.invoke(null);

      for(int x=0; x<lsVal.length; x++)
      System.out.println("element " + x + ": " + lsVal[x]);
    }
    catch(Throwable th)
    {
      th.printStackTrace();
    }
  }
	
  public void myInit() {
    try {
      // just call the wsdl with mention of the service name
      QName serviceName = new QName(
	"http://www.pascalbotte.be:80/rcx-ws-rpc/rcx?WSDL",
	"MyRcxService");
      ServiceFactory factory = ServiceFactory.newInstance();
      service = factory.createService(serviceName);
			
      TypeMappingRegistry registry = service.getTypeMappingRegistry();
      typeMapping = registry.getTypeMapping(SOAPConstants.URI_ENCODING);	
										
      // register int array type
									
      intArrayTypeQname = new QName( "http://phonedirlux.homeip.net/types" ,
	"ArrayOfint"); //typenamespace 	
		
      QName intArrayElementQname = new QName("", "int");
		
      CombinedSerializer intSerializer = new
	SimpleTypeSerializer(QNAME_TYPE_INT, DONT_ENCODE_TYPE, NULLABLE,
	  SOAPConstants.URI_ENCODING, XSDIntEncoder.getInstance());
				
      CombinedSerializer intArraySerializer = new
	SimpleTypeArraySerializer(intArrayTypeQname, ENCODE_TYPE, NULLABLE,
	  SOAPConstants.URI_ENCODING, null , QNAME_TYPE_INT,
	  int.class, 1, null, (SimpleTypeSerializer)intSerializer);
      intArraySerializer = new
	ReferenceableSerializerImpl(SERIALIZE_AS_REF,
	  intArraySerializer);
							
      SerializerFactory intArraySerializerFactory = new
	SingletonSerializerFactory(intArraySerializer);
      DeserializerFactory intArrayDeserializerFactory = new
	SingletonDeserializerFactory(intArraySerializer);

      typeMapping.register(int[].class, intArrayTypeQname,   
        intArraySerializerFactory, intArrayDeserializerFactory);		
	
      //end of register int array type										
    }
    catch (Throwable t) {
      t.printStackTrace();
    }	
  }
}

We see here that it is still possible to consume a remote procedure returning an array of simple type, using the DII technique, without the need of an external tool. Just register your serializer/deserializer using the technique explained for the sei example, see: register array of simple type

1.4.3. Consume a remote procedure returning an object with DII (rpc/encoded)

Unfortunately, using DII we will already need to use the TypeMapping for registering purpose of our RcxResponse object and also wscompile tool to generate the RcxResponse_SOAPSerializer deserializer class. Feel free to check how to generate this class here.

Note

We will need another file in this specific case: RcxResponse_SOAPBuilder.java (needed by RcxResponse_SOAPSerializer.java), copy also the RcxResponse.java file.

Like usually, we have to register our RcxResponse type, so add the following code in the myInit() function, just after the registration of the int[] type.

//	start of register Response complex type object

        rcxResponseQname = new QName("http://phonedirlux.homeip.net/types", "rcxResponse");
								
	CombinedSerializer rcxResponseSerializer = new RcxResponse_SOAPSerializer(rcxResponseQname, 
		ENCODE_TYPE, NULLABLE, SOAPConstants.URI_ENCODING);
  	rcxResponseSerializer = new ReferenceableSerializerImpl(SERIALIZE_AS_REF, rcxResponseSerializer);
	SerializerFactory rcxResponseSerializerFactory = new SingletonSerializerFactory(rcxResponseSerializer);
	DeserializerFactory rcxResponseDeserializerFactory = new SingletonDeserializerFactory(rcxResponseSerializer);

	typeMapping.register(RcxResponse.class, rcxResponseQname, rcxResponseSerializerFactory, 
		rcxResponseDeserializerFactory);

// end of register Response complex type object

You can add to your class the function below to create the call:

  public void callReadResponse( )
  {
    try
      {
	// Create the Call object using Service
        Call call = service.createCall();	
				
	QName operationName = new QName(
	  "http://phonedirlux.homeip.net/wsdl", "status");
	call.setOperationName(operationName);
						
	call.setReturnType(rcxResponseQname);
	// The operation is an RPC-style operation.
	call.setProperty(
	  Call.OPERATION_STYLE_PROPERTY, "rpc");
	    
	call.setProperty(
	  Call.ENCODINGSTYLE_URI_PROPERTY,
          "http://schemas.xmlsoap.org/soap/encoding/");
	// The target endpoint
	call.setTargetEndpointAddress(
	  "http://www.pascalbotte.be/rcx-ws-rpc/rcx");
   			  
	RcxResponse respVal = (RcxResponse)call.invoke(null);
						  
	System.out.println("Object response:\n" + 
	  "\t- Status: " + respVal.getStatus() +
	  "\n\t- Memory free: " + respVal.getMemory() +
	  "\n\t- Memory total: " + respVal.getMemoryTot() +
	  "\n\t- Battery level: " + respVal.getBattery() +
	  "\n\t- Time: " + respVal.getCurrentTime());
      }
      catch(Throwable th)
      {
        th.printStackTrace();
      }
  }

Then make the call:

RcxClientObj.callReadResponse();

Now execute your client and you should see some internal value of my RCX. If my RCX brick is down you can mail me at pascal botte I will turn it on if possible.

1.4.4. DII client: remote procedure returning an array of object (rpc/encoded)

And what about to consume a remote procedure returning an array of object (like our collPos() function with a return type of PosCol[] class). The class PosCol is a simple class with two integer value (XPos and YPos) supposed to define a position.

First, we have to copy two new files generated by the wscompile tool: PosCol.java and PosCol_SOAPSerializer.java. Like usually, put these files in your /diiclient directory. Now we are ready to add some more code to our client class.

Add the lines below to register our PosCol[] type.

// start of register PosCol complex type object + array

        // don't forget to define PosColQname and PosColArrayTypeQname as a QName type member of your class
        PosColQname = new QName("http://phonedirlux.homeip.net/types", "PosCol");

   	PosColArrayTypeQname = new QName( "http://phonedirlux.homeip.net/types" ,
          "ArrayOfPosCol");  
   	QName PosColArrayElementQname = new QName("","PosCol");
								
	CombinedSerializer PosColSerializer = new PosCol_SOAPSerializer(PosColQname,
          ENCODE_TYPE, NULLABLE, SOAPConstants.URI_ENCODING);
	PosColSerializer = new 
          ReferenceableSerializerImpl(SERIALIZE_AS_REF, PosColSerializer);
	SerializerFactory PosColSerializerFactory = 
          new SingletonSerializerFactory(PosColSerializer);
	DeserializerFactory PosColDeserializerFactory = 
          new SingletonDeserializerFactory(PosColSerializer);

					 
	CombinedSerializer PosColArraySerializer = 
          new ObjectArraySerializer(PosColArrayTypeQname, 
            ENCODE_TYPE, NULLABLE, SOAPConstants.URI_ENCODING, 
            PosColArrayElementQname, PosColQname, PosCol.class, 1, null);
	PosColArraySerializer = 
          new ReferenceableSerializerImpl(SERIALIZE_AS_REF, PosColArraySerializer);
	SingletonSerializerFactory PosColArraySerializerFactory = 
          new SingletonSerializerFactory(PosColArraySerializer);
	SingletonDeserializerFactory PosColArrayDeserializerFactory = 
          new SingletonDeserializerFactory(PosColArraySerializer);			 

	typeMapping.register(PosCol.class, PosColQname, 
          PosColSerializerFactory, PosColDeserializerFactory);
	typeMapping.register(PosCol[].class, PosColArrayTypeQname, 
          PosColArraySerializerFactory, PosColArrayDeserializerFactory);

// end of register PosCol complex type object + array

Add the import directive:

import com.sun.xml.rpc.encoding.ObjectArraySerializer;

Now, add the function below to make the call:

public void callCollPos( )
{
    try
    {
	//	Create the Call object using Service
	Call call = service.createCall();
	QName operationName = new QName(
	   "http://phonedirlux.homeip.net/wsdl",
	   "collPos"); 
	call.setOperationName(operationName);			 
	// The return
	call.setReturnType(PosColArrayTypeQname);				   
	// The operation is an RPC-style operation.
	call.setProperty(
	   Call.OPERATION_STYLE_PROPERTY,
	   "rpc");
	call.setProperty(
	   Call.ENCODINGSTYLE_URI_PROPERTY,
	   "http://schemas.xmlsoap.org/soap/encoding/");
	// The target endpoint
	call.setTargetEndpointAddress(
	   "http://www.pascalbotte.be/rcx-ws-rpc/rcx");
	// Invoke the method collPos
	PosCol[] pcaVal =  (PosCol[])call.invoke(null);
	for(int x=0; x < pcaVal.length; x++)
	   System.out.println("element " + x + 
	   "\n\tx: " + pcaVal[x].getXPos() + ", y: " + pcaVal[x].getYPos() + "\n");			
     }
     catch(Throwable th)
     {
	th.printStackTrace();
     }
}

You are ready to make the call:

RcxClientObj.callCollPos();

1.4.5. DII client for document/literal operation style

If you want to use JAX-RPC for a DII client, for a document/literal web service, you must use wscompile, even for a procedure returning a simple type. Then could we really call that DII? This example comes from the JWSDP 1.3 tutorial, advanced clients samples (DIINoWSDLHelloClient). I decided to choose the no-WSDL access method because we have to generate our wrapper class prior to make the call - in all the cases -, so we have less interest to read the WSDL at runtime for a document/literal web service.

Here, I had to make a little adaptation on a file generated by wscompile: the wrapper for the class ReadLS(request type for the rpc String readLS(String) has a variable "string_1" and not "String_1", like in the WSDL. So you have to change that variable's name in the file ReadLS.java for a correct wrapper treatment. You won't probably encounter the problem if you use the last JAX-RPC package or JWSDP 1.4.

Note: See here for how to use wscompile. For this example replace the option -gen by -import and add -f:wsi, do not forget to eventually change the package name in the file config.xml.

Example 1-8. DII client version for document/literal web service.

Create a client with wscompile is really easy, so I demo here all the method call already covered by the preceding section in one example.

package diiclient;

import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
//import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ParameterMode;

public class RcxClient {

    // In the WSDL under definitions. This is the target namespace.
    private static String BODY_NAMESPACE_VALUE =
            "http://phonedirlux.homeip.net/wsdl";

    // In the WSDL under types. This is the namespace that is defined for
    // types defined in the WSDL.
    private static String TYPE_NAMESPACE_VALUE =
             "http://phonedirlux.homeip.net/types";

    private static String ENCODING_STYLE_PROPERTY =
            "javax.xml.rpc.encodingstyle.namespace.uri";
    private static String NS_XSD =
            "http://www.w3.org/2001/XMLSchema";
    private static String URI_ENCODING =
            "http://schemas.xmlsoap.org/soap/encoding/";

    // The endpoint must be supplied by the service deployer or developer.
    // It may also be found in the WSDL under address.
    String endpoint = null;

    // Service name from the WSDL.
    String serviceName = null;

    // Port name from the WSDL.
    String portName = null;

    Service service = null;
    QName port = null;

    public static void main(String[] args) {

        try {
		RcxClient obj = new RcxClient();
		obj.testEchoString();    // take a string as param and return a string
                obj.readLSpercent();     // take an int as param and return an int
		obj.readTemp();          // take an int as param and return a float
		obj.status();            // return an object (RcxResponse)
		obj.collInt();           // return an array of int
		obj.collPos();           // return an array of object (PosCol)


        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public RcxClient() {

		serviceName = "MyRcxService";
		portName = "RcxReadLSPort";

        try {

           // Get the service factory using the newInstance() method.
            ServiceFactory factory =
                    ServiceFactory.newInstance();

            // Create the service using the QName of the service.
	    // Since the WSDL is not being read at runtime this service
	    // is not configured.
            service =
                    factory.createService(new QName(serviceName));

            // Specify the port QName using the portName.
            port = new QName(portName);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void testEchoString() throws Exception {

		endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";

		// Operation QName as specified in the WSDL under portType section.
	
		QName operation = new QName(BODY_NAMESPACE_VALUE, "readLS");

	
try {
        Call call = service.createCall(port, operation);

		// The developer must set the endpoint address.
        call.setTargetEndpointAddress(endpoint);

		// For a call object, the developer must set these Call properties.
        call.setProperty(Call.SOAPACTION_USE_PROPERTY,
                new Boolean(true));
        call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");

		// The encoding style property and the operation style property
		// must be set for a WS-I doc/lit or rpc/lit type of invocation
    	// Although these properties are specified in the JAX-RPC Specification
    	// as optional, the default behavior for this implementation is rpc/encoded.

    	// use="literal" in WSDL
        call.setProperty(ENCODING_STYLE_PROPERTY, "");
    	// style="document" in WSDL
        call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");

        QName REQUEST_QNAME = new QName(TYPE_NAMESPACE_VALUE, "readLS");
        // the first parameter come from the WSDL after "types", under "message"->"part": name
        call.addParameter("parameters", REQUEST_QNAME, diiclient.ReadLS.class,
                ParameterMode.IN);
        // note here, on my system, the following line worked fine:
        // call.addParameter("", REQUEST_QNAME, 
        //        ParameterMode.IN);
    
        QName RESPONSE_QNAME = new QName(TYPE_NAMESPACE_VALUE, "readLSResponse");
        call.setReturnType(RESPONSE_QNAME, diiclient.ReadLSResponse.class);

    	// Instantiate the parameter(s) and populate the call Object[] request.
    	
        System.out.println("Running readLS from a dii client (with no WSDL access).");
        ReadLS request = new ReadLS("your message here or your e-mail");
        Object[] params = {request};
	
    	// Invoke readLS:
        ReadLSResponse response = (ReadLSResponse) call.invoke(params);

    	// Print result.
        System.out.println("Response is: " + response.getResult());
        System.out.println(" ");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }	
    public void readLSpercent() throws Exception {
		  
	endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";

	QName operation = new QName(BODY_NAMESPACE_VALUE, "readLSpercent");

        try {
	  Call call = service.createCall(port, operation);

	  call.setTargetEndpointAddress(endpoint);

	  call.setProperty(Call.SOAPACTION_USE_PROPERTY,
				   new Boolean(true));
	  call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");

	  call.setProperty(ENCODING_STYLE_PROPERTY, "");
		  
	  call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");

          QName REQUEST_QNAME = new QName(TYPE_NAMESPACE_VALUE, "readLSpercent");
	   
	  call.addParameter("parameters", REQUEST_QNAME, diiclient.ReadLSpercent.class,
				   ParameterMode.IN);
	   
	  QName RESPONSE_QNAME = new QName(TYPE_NAMESPACE_VALUE, "readLSpercentResponse");
	  call.setReturnType(RESPONSE_QNAME, diiclient.ReadLSpercentResponse.class);

	  System.out.println("Running readLSpercent from a dii client.");
	  ReadLSpercent request = new ReadLSpercent(1);
	  Object[] params = {request};
	
	  // Invoke readLSpercent
	  ReadLSpercentResponse response = (ReadLSpercentResponse) call.invoke(params);

	  // Print result.
	  System.out.println("Light sensor value: " + response.getResult());
	  System.out.println(" ");
       } catch (Exception ex) {
	  ex.printStackTrace();
       }
    }
	   
    public void readTemp() throws Exception {
		  
      endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";

      QName operation = new QName(BODY_NAMESPACE_VALUE, "readTemp");

      try {
	Call call = service.createCall(port, operation);

	call.setTargetEndpointAddress(endpoint);

	call.setProperty(Call.SOAPACTION_USE_PROPERTY,
					   new Boolean(true));
	call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");

	call.setProperty(ENCODING_STYLE_PROPERTY, "");
		  
	call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");

	QName REQUEST_QNAME = new QName(TYPE_NAMESPACE_VALUE, "readTemp");
	   
	call.addParameter("parameters", REQUEST_QNAME, diiclient.ReadTemp.class,
					   ParameterMode.IN);
	   
	QName RESPONSE_QNAME = new QName(TYPE_NAMESPACE_VALUE, "readTempResponse");
	call.setReturnType(RESPONSE_QNAME, diiclient.ReadTempResponse.class);

	System.out.println("Running readLSpercent from a dii client.");
	ReadTemp request = new ReadTemp(1);
	Object[] params = {request};
	
	// Invoke readTemp
	ReadTempResponse response = (ReadTempResponse) call.invoke(params);

	// Print result.
	System.out.println("Temperature sensor value: " + response.getResult());
	System.out.println(" ");
     } catch (Exception ex) {
	ex.printStackTrace();
     }
   }
		   
   public void status() throws Exception {
		  
     endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";

     QName operation = new QName(BODY_NAMESPACE_VALUE, "status");

     try {
	Call call = service.createCall(port, operation);

	call.setTargetEndpointAddress(endpoint);

	call.setProperty(Call.SOAPACTION_USE_PROPERTY,
					   new Boolean(true));
	call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");

	call.setProperty(ENCODING_STYLE_PROPERTY, "");
		  
	call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");

	QName REQUEST_QNAME = new QName(TYPE_NAMESPACE_VALUE, "status");
	   
	call.addParameter("parameters", REQUEST_QNAME, diiclient.Status.class,
					   ParameterMode.IN);
	   
	QName RESPONSE_QNAME = new QName(TYPE_NAMESPACE_VALUE, "statusResponse");
	call.setReturnType(RESPONSE_QNAME, diiclient.StatusResponse.class);

        System.out.println("Running status from a dii client.");
	Status request = new Status();
	Object[] params = {request};
	
	// Invoke status
	StatusResponse response = (StatusResponse) call.invoke(params);
			   
	RcxResponse rcxResponseObj = response.getResult();

	// Print result.
	System.out.println("Rcx message: " + rcxResponseObj.getStatus());
	System.out.println("Memory free: " + rcxResponseObj.getMemory());
	System.out.println("Memory total: " + rcxResponseObj.getMemoryTot());
	System.out.println("Internal clock: " + rcxResponseObj.getCurrentTime());
	System.out.println(" ");
     } catch (Exception ex) {
	ex.printStackTrace();
     }
   }

   public void collInt() throws Exception {
		  
     endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";

     QName operation = new QName(BODY_NAMESPACE_VALUE, "collInt");

     try {
	Call call = service.createCall(port, operation);

	call.setTargetEndpointAddress(endpoint);

	call.setProperty(Call.SOAPACTION_USE_PROPERTY,
						   new Boolean(true));
	call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");

	call.setProperty(ENCODING_STYLE_PROPERTY, "");
		  
	call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");

	QName REQUEST_QNAME = new QName(TYPE_NAMESPACE_VALUE, "collInt");
	   
	call.addParameter("parameters", REQUEST_QNAME, diiclient.CollInt.class,
						   ParameterMode.IN);
	   
	QName RESPONSE_QNAME = new QName(TYPE_NAMESPACE_VALUE, "collIntResponse");
	call.setReturnType(RESPONSE_QNAME, diiclient.CollIntResponse.class);

	System.out.println("Running collInt from a dii client.");
	CollInt request = new CollInt();
	Object[] params = {request};
	
	// Invoke collInt
	CollIntResponse response = (CollIntResponse) call.invoke(params);
	int[] myIntArray = response.getResult();
	// Print result.
	System.out.println("Consume the method collInt (returning an array of int): ");
	for (int x=0; x < myIntArray.length; x++) 
	  System.out.println("integer" + x + ": "+ myIntArray[x]);
	System.out.println(" ");
     } catch (Exception ex) {
	ex.printStackTrace();
     }
   }
		   
   public void collPos() throws Exception {
		  
     endpoint = "http://www.pascalbotte.be/rcx-ws/rcx";

     QName operation = new QName(BODY_NAMESPACE_VALUE, "collPos");

     try {
	Call call = service.createCall(port, operation);

	call.setTargetEndpointAddress(endpoint);

	call.setProperty(Call.SOAPACTION_USE_PROPERTY,
		         new Boolean(true));
	call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");

	call.setProperty(ENCODING_STYLE_PROPERTY, "");
		  
	call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");

	QName REQUEST_QNAME = new QName(TYPE_NAMESPACE_VALUE, "collPos");
	   
	call.addParameter("parameters", REQUEST_QNAME, diiclient.CollPos.class,
			  ParameterMode.IN);
	 
	QName RESPONSE_QNAME = new QName(TYPE_NAMESPACE_VALUE, "collPosResponse");
	call.setReturnType(RESPONSE_QNAME, diiclient.CollPosResponse.class);

	System.out.println("Running a method returning an array of object from a dii client.");
	CollPos request = new CollPos();
	Object[] params = {request};
	
	// Invoke collPos
	CollPosResponse response = (CollPosResponse) call.invoke(params);
	PosCol[] myPCArray = response.getResult();
	// Print result.
	for (int x=0; x < myPCArray.length; x++) 
	  System.out.println("Position " + x + ": x->"+ myPCArray[x].getXPos() + ", y->" + myPCArray[x].getYPos());
	System.out.println(" ");
     } catch (Exception ex) {
	ex.printStackTrace();
     }
   }
}