JAX-RPC and non-primitive data types

Hello all!
I am using JWSDP v1.3 and i have a problem using non-primitive data types as return types for my operations.
Consider the helloservice example of the JWSDP1.3 tutorial. Now suppose that instead of having the simple operation sayHello() that returns a String, we execute a query on a database, get some ResultSetMetaData and we want these Metadata to be the return type of our operation. I.e. have the operation
public ResultSetMetaData sayHello()
instead of the
public String sayHello()
of the tutorial.
When trying to build the service i get the following error which is normal, because ResultSetMetaData is not a supported JAX-RPC type.
run-wscompile: [echo] Running wscompile: [echo] C:\jwsdp\apache-ant\../jaxrpc/bin/wscompile.bat -define -d build - nd build -classpath build config-interface.xml -model build/model. gz [exec] error: invalid type for JAX-RPC structure: java.sql.ResultSetMetaData [exec] Result: 1
Is there any way to define an operation like this? Can i specify somehow ResultSetMetaData as a supported-type?
I hope someone can give me some advice on it, because i have lost one evening trying to figure it out myself :)
Regards,
Kostas

Courtesy links to crossposts so people don't waste their time answering a question which has already been answered
http://forum.java.sun.com/thread.jsp?thread=482875&forum=59&message=2253704
http://forum.java.sun.com/thread.jsp?thread=482873&forum=331&message=2253699

Similar Messages

  • Primitive v/s Non-primitive data type

    Hi,
    I am new to java. What is the difference between primitive and non-primitive data type?

    hi Anand,
    there are hundred thousands of object in the Data Dictionary, so 15 won't harm much On the other hand, if you build up an ALV list based on this table, than it is good that you have these texts there with translations, etc.
    hope this helps
    ec

  • JAX-RPC And Non-Java Web Service

    Hi,
    This is a total shot in the dark. I'm attempting to consume an RPC web service developed in Delphi. I've created a JAX-RPC client in NetBeans from the published WSDL, attached below. I've created calls to several of the procedures available. What's bizarre, at least to me, is that half of them work fine and half of them don't. In all cases where they don't I'm getting a returns SOAP envelope indicated an access violation, attached below. There are no errors in any of the server logs and the developer assures me that the procedures do, in fact, work from his client (also developed conveniently enough in Delphi).
    I'm willing to take him at face value for the moment and assume that the problem is in my client implementation, although I have no idea where it would lie. The only difference I've been able to gather between the features which work and those that don't is the size of the return package...it would most likely be much larger than the ones that don't work.
    The service is an ISAPI dll running under IIS on Windows Server 2003. Any clues or guidance anyone would be willing to provide would be most welcome. On to the files:
    There wasn't enough room to post the entire thing so I've included one working (CheckStock) and non-working (GetLibTrace) function.
    WSDL:
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="IInnovaServiceservice" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">
      <message name="CheckStock2Request">
        <part name="OPC" type="xs:string"/>
      </message>
      <message name="CheckStock2Response">
        <part name="QTY" type="xs:int"/>
        <part name="messages" type="xs:string"/>
        <part name="return" type="xs:int"/>
      </message>
      <message name="GetLibTrace5Request">
        <part name="LibName" type="xs:string"/>
      </message>
      <message name="GetLibTrace5Response">
        <part name="dimensions" type="xs:string"/>
        <part name="messages" type="xs:string"/>
        <part name="return" type="xs:int"/>
      </message>
      <portType name="IInnovaService">
        <operation name="CheckStock">
          <input message="tns:CheckStock2Request"/>
          <output message="tns:CheckStock2Response"/>
        </operation>
        <operation name="GetLibTrace">
          <input message="tns:GetLibTrace5Request"/>
          <output message="tns:GetLibTrace5Response"/>
        </operation>
      </portType>
      <binding name="IInnovaServicebinding" type="tns:IInnovaService">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="CheckStock">
          <soap:operation soapAction="urn:InnovaServiceIntf-IInnovaService#CheckStock" style="rpc"/>
          <input>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </input>
          <output>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </output>
        </operation>
        <operation name="GetLibTrace">
          <soap:operation soapAction="urn:InnovaServiceIntf-IInnovaService#GetLibTrace" style="rpc"/>
          <input>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </input>
          <output>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </output>
        </operation>
      </binding>
      <service name="IInnovaServiceservice">
        <port name="IInnovaServicePort" binding="tns:IInnovaServicebinding">
          <soap:address location="http://172.20.10.145:8080/innovaservice.dll/soap/IInnovaService"/>
        </port>
      </service>
    </definitions>My client:
    package com.signet.innova.client;
    import com.signet.innova.client.interfaces.IInnovaService;
    import com.signet.innova.client.interfaces.IInnovaServiceservice_Impl;
    import java.net.URL;
    import java.rmi.RemoteException;
    import java.util.ArrayList;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.Stub;
    import javax.xml.rpc.holders.Holder;
    import javax.xml.rpc.holders.IntHolder;
    import javax.xml.rpc.holders.StringHolder;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.ws.Dispatch;
    import javax.xml.ws.Service;
    public class InnovaClient {
        private void testConnection() {
            Stub stub = createProxy();
            IInnovaService service = (IInnovaService) stub;
            StringHolder sh1 = new StringHolder();
            StringHolder sh2 = new StringHolder();
            StringHolder sh3 = new StringHolder();
            IntHolder ih1 = new IntHolder();
            IntHolder ih2 = new IntHolder();
            IntHolder ih3 = new IntHolder();
            try {
                System.out.println("Calling checkStock()");
                service.checkStock("0103877866", ih1, sh1, ih2);
                System.out.println(" service returned => " + ih1.value + ":" + sh1.value + ":" + ih2.value);
            } catch (RemoteException re) {
                System.out.println(" service returned => " + re.toString());
            try {
                System.out.println("Calling getLibTrace()");
                service.getLibTrace("REGULAR", sh1, sh2, ih3);
                System.out.println(" service returned => " + sh1.value + ":" + sh2.value + ":" + ih1.value);
            } catch (RemoteException re) {
                System.out.println(" service returned => " + re.toString());
        private Stub createProxy() {
            return (Stub) (new IInnovaServiceservice_Impl().getIInnovaServicePort());
        public static void main(String[] args) {
            InnovaClient client = new InnovaClient();
            System.out.print("Running testConnection()...");
            client.testConnection();
    }The request and response packets are in my reply below. Ran out of characters. :o)
    Edited by: Pablo_Vadear on Dec 22, 2009 11:19 PM

    Correction from above...".it would most likely be much larger than the ones that don't work" should have been "it would most likely be much larger IN THE ONES THAT DON'T WORK". Sorry.
    The request:
    POST /innovaservice.dll/soap/IInnovaService HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Content-Length: 484
    SOAPAction: "urn:InnovaServiceIntf-IInnovaService#CheckStock"
    User-Agent: Java/1.6.0_17
    Host: 172.20.10.145:8080
    Connection: keep-alive
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:InnovaServiceIntf-IInnovaService" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><env:Body><ns0:CheckStock><OPC xsi:type="xsd:string">0103877866</OPC></ns0:CheckStock></env:Body></env:Envelope>POST /innovaservice.dll/soap/IInnovaService HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Content-Length: 491
    SOAPAction: "urn:InnovaServiceIntf-IInnovaService#GetLibTrace"
    User-Agent: Java/1.6.0_17
    Host: localhost:8080
    Connection: keep-alive
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:InnovaServiceIntf-IInnovaService" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><env:Body><ns0:GetLibTrace><LibName xsi:type="xsd:string">REGULAR</LibName></ns0:GetLibTrace></env:Body></env:Envelope>And the response:
    <?xml version="1.0"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><NS1:CheckStockResponse xmlns:NS1="urn:InnovaServiceIntf-IInnovaService"><return xsi:type="xsd:int">0</return><QTY xsi:type="xsd:int">0</QTY><messages xsi:type="xsd:string">Item 0103877866 retrieved OK.
    Right side OPC.
    </messages></NS1:CheckStockResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
    HTTP/1.1 200 OK
    Date: Tue, 22 Dec 2009 23:18:40 GMT
    Server: Microsoft-IIS/6.0
    Content-Type: text/xml
    Content-Length: 486
    <?xml version="1.0"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultactor/><faultcode>SOAP-ENV:Server</faultcode><faultstring>Access violation at address 00000000. Write of address 00000000</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>Any help appreciated.
    Edited by: Pablo_Vadear on Dec 22, 2009 11:23 PM

  • JAX-RPC 9.0.4   --- Data Types Supported

    Hi,
    does any body know is java.util.List is a supported Datatype on OC4j 9.0.4.2 for JAX-RPC.
    Cheers
    Gaurav

    Gaurav,
    Not sure which version of JAX-RPC you are intended to run on top of 9.0.4.2 ?
    In any way, if you want your service to work with the majority of the clients, you need to focus on the XML types; not the java types.
    To my knowledge, the List will be mapped to a proprietary type, at best, which make it harder to re-use.
    All the best,
    Eric

  • Runtime conversion of a string value to a primitive data type in java

    can anyone of you give me an idea to convert a string value to a primitive data type during run time...i have the value and the type to which it has to be converted as String values...do you have any idea ,...pls share

    String recvalvalue = inputval;
                    String recvartype = inputtype;
                   if (recvartype.equals("int")){
                   value0 = Integer.parseInt(recvalvalue);
             else
             if (recvartype.equals("double")){
                    value1  = Double.parseDouble(recvalvalue);
             else
             if(recvartype.equals("float")){
              value2 = Float.parseFloat(recvalvalue);
             else
             if(recvartype.equals("Boolean")){
              value3 = Boolean.parseBoolean(recvalvalue);
             else
             if(recvartype.equals("char")){
               value4 = (char)recvalvalue.charAt(0);
            else
            if(recvartype.equals("String")){
              value5 = recvalvalue;
             else
             if(recvartype.equals("byte")){
               value6 = Byte.parseByte(recvalvalue);
                  //listA.add(6, value6);
                  //     listA.g = value6;
             else
              if(recvartype.equals("long")){
               value7 = Long.parseLong(recvalvalue);
             else
              if(recvartype.equals("short")){
              value8 = Short.parseShort(recvalvalue);
             } yes i can do this but the resultant value has to be assigned to a variable of a specific type which is here recvartype .....it has to be done dynamically automatically..if we know what type of data is that we can convert and assign to the type but we donot know when we run the program as the program will be supllied by someone and has to be executed

  • Creation of new primitive data types

    Is it possible to create primitive data types? Or perhaps there's another solution...
    I have a need to work with signed integers represented by more than 128 bits, and would prefer to define such variables as primitive types and be able to use them as such. I have no problem creating "toString()" and friends for convert binary to decimal.
    Thanks in advance.
    Randolf Richardson - [email protected]
    Inter-Corporate Computer & Network Services, Inc.
    Vancouver, British Columbia, Canada
    http://www.8x.ca/

    What about using "BigIntegers"?
    http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html

  • Retrieving spatial and non spatial data in one query

    Hello. I am having slight difficulties using JDBC to retrieve both spatial and non spatial data in the same query. The following is code from a sample program of mine that retrives spatial data from spatial tables.
    (In spatialquery geom is a geometry column and city is simply the name of the city):
    try
    Geometry geom = null;
    String database = "jdbc:oracle:thin:@" + m_host + ":" + m_port + ":" + m_sid;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = (OracleConnection)DriverManager.getConnection(database, sUsername, sPassword);
    GeometryAdapter sdoAdapter =
    OraSpatialManager.getGeometryAdapter("SDO", "8.1.7", STRUCT.class, null, null, con);
    String spatialquery = "SELECT a1.geom, a1.city \n" +
    "FROM cities a1";
    Statement stmt = con.createStatement();
    OracleResultSet rs = (OracleResultSet) stmt.executeQuery(spatialquery);
    int i = 0;
    int noOfFeatures = 2;
    while (rs.next())
    for(i = 1; i <= noOfFeatures; i++)
    STRUCT dbObject = (STRUCT)rs.getObject(i);
    try
    geom = sdoAdapter.importGeometry(dbObject);
    catch(GeometryInputTypeNotSupportedException e)
    System.out.println("Input Type not supported");
    catch(InvalidGeometryException e)
    System.out.println("Invalid geometry");
    System.out.println(geom);
    }//end while loop
    This retrieves the sptial data fine, however when I attempt to retreive the non-spatial data I keep getting a "ClassCastException" error. I understand it is something to do with "STRUCT dbObject = (STRUCT)rs.getObject(i);" line. Can anyone tell me how to retrieve both spatial and non-spatial data in the one query using JDBC. I have tried nearly everything at this stage. Cheers joe

    Theresa A Radke
    Posts: 20
    OTN Member Since: Jul, 2001
    retrieving spatial and non spatial in same query. May 23, 2003 12:02 AM
    retrieving spatial and non spatial in same query.

  • Should Java introduce new primitive data types??

    In Java SE 5.0, many character- related methods (especially in the class Character) handle code points by using int type, i.e. return (code point) type is int, or receive (code point) int as parameter. This leads several problems. First, the variable used for storing returned result should be carefully stated, otherwise confusion may arise. Second, the parameters of method should be carefully ordered, otherwise conflict of method signature may meet.
    By those reasons, I suggest that Java should introduce new primitive data types for handling characters, they are:
    1. wchar
    this type states the variable stores 32-bit UNSIGNED integer, and it could be used to store either the code point, or the UTF-16 code of a character.
    2. ascii
    this type states the variable stores 8-bit UNSIGNED integer, and it could be used to store the code point of a elemental (ascii) character.

    short char, no. Nononono.
    No.
    wchar, I think I'd pref to see Java version 2 come
    out, and that be wchar by default, but that is not
    going to happen.
    I don't see a great need for it at this time.http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504839
    Though I do not think that Java developer would like to change too much program code for using proposed (unsigned) primitive data types, I still believe that Java developer will eventually introduce these types, because it is not efficient to pretend signed integer to unsigned integer, and the success of a programming language is determined by how it can meet the programmers' need.

  • Primitive data types as a sequence of bytes

    Does anyone have any experience of converting between primitive data types and sequences (i.e. arrays) of bytes? In particular I want to transmit primitive data types over a socket connection by writing a sequence of bytes.
    Thanks in advance.

    Yes. My personal favourite class for this is java.nio.ByteBuffer though you can also do it with java.io.DataInputStream/DataOutputStream and that might work better with sockets. ByteBuffer is particularly useful with pre-specified formats since you can specify big/little endian storage.

  • JAX-RPC and Parameter Interfaces

    I am designing the Web Service interface for our project using JAX-RPC, and have enjoyed the ease with which I can create Web Service deployments and WSDL documents.
    However, some of the developers on my team have chosen to create their Data Transfer Objects as a pair of Interface and Implementation classes. This works okay in scenario where the WS caller is "pulling" data from my service. However, it doesn't work in the scenario where the caller is "pushing" data to the service because JAX-RPC can't make the connection between the interface and implementation classes used in my service interface.
    For example, suppose there are four classes in the project: MyService, MyServiceImpl, Foo, and FooImpl. The MyService class uses Foo in it's method signatures. How does JAX-RPC know to instantiate an instance of FooImpl for incoming requests?
    public class MyServiceImpl implements MyService {
    // not ok
    public void doStuff (Foo arg) { ... }
    // ok
    public Foo giveMeStuff () { ... }
    It would be nice if JAX-RPC provided annotations that facilitated making connections between interfaces and implementation classes used in service inputs and outputs. For example:
    @WebServiceInterface {
    Implementation=FooImpl
    public Foo {
    Any thoughts? Thanks,
    Scott Kidder
    http://urlgrey.net/

    Found some answer from the following link
    http://forum.java.sun.com/thread.jsp?forum=331&thread=465860

  • Jax-rpc and soap

    I have implemented a web service using jax-rpc and soap however i am unsure how to go about validating my soap package with my own schema before using the web service. How do i use my own schema to validate this, i think it may be with the wsdl file but i am not sure. At present the wsdl file points to a non existing .xsd file which the soap envelope uses, what i need i to replace this with my own schema, or is there a better way to do this than using jax-rpc and soap?
    cheers
    Andy

    I am in the same situation as you are. Got any solution? please let me know.
    Appreciate your valuable reply

  • Setting precision to primitive data types

    How can I set precisions to the primitive data types, viz, double and float??
    I'm writing a program in which I've declared a double variable as follows :
    double d=12.00
    System.out.println(d);
    The output is 12.0 but I want it to be 12.00
    How can it be done??

    You have to use a BigDecimal:
            BigDecimal bd = new BigDecimal(12);
            bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
            System.out.println(bd);

  • JAVA primitive data types - Signed/ unsigned etc.

    1. Are the following data types signed or unsigned in JAVA?
    byte, short, int, long, float, double
    2. I have tried using "Integer" in place of "int" and the program runs perfectly. Why is this so when "Integer" is not a reserved word in JAVA?
    Thanks.

    And to answer your first question, byte, short, int, long, float and double are all signed.
    As a part of the core of the language, Sun developed a series of 'collections' classes; Vector, ArrayList, etc. All of these classes, in the days before generics, were able to store instances of the Object class or anything that derived from it. Therefore, to store an int, a float or a double value into one of these collections classes, it was necessary to wrap it up in an instance of one of those classes that derived from Number. These are the wrapper classes that the previous poster alluded to. Typically, the wrapper class has a similar name to the primitive data type but with a capital latter; int - Integer, double - Double, etc.

  • Transferring primitive data types via UDP other than a String

    Hi ALL,
    I am new to Socket programming in UDP.
    I need to implement a FTP client-server application.
    Now the packet that I need to transfer using UDP as a DatagramPacket consists of multiple primitive data types, (3short types and 1 byte array of size 265.)
    How do I do that?
    All the samples and examples I managed to find on the Internet illustrated the problem of transferring a String type converted to getBytes and the byteArray is transferred.
    However, in my case i need to pass this structure..(3fields) to the other side. If I convert the 4 fields to a single concatenated string there's this problem of finding out where each of the four fields begin and where do they end.
    Please suggest and help...
    thanks..
    : )

    Just create a class that represents your structure and convert-it to a byte array that can be sended over a DatagramSocket.
    Try this sample code :
    import java.io.*;
    import java.net.*;
    public class DP
        /** Creates a new instance of DP */
        public DP ()
         * @param args the command line arguments
        public static void main (String[] args)
            try
                System.out.println ("Starting server ...");
                DatagramServerThread server = new DatagramServerThread ("Datagram server");
                server.start ();
                System.out.println ("Creating your object ...");
                ByteArrayOutputStream baos = new ByteArrayOutputStream (); // Creating byte array output stream ..
                ObjectOutputStream oos = new ObjectOutputStream (baos);// Creating a object output stream that writes to byte array output stream..
                YourStructure newObject = new YourStructure (); // creating your data structure..
                newObject.setShortField1 ((short)12);// setting values ...
                newObject.setShortField2 ((short)45);
                newObject.setShortField3 ((short)4);
                newObject.setArray (new byte [256]);
                oos.writeObject (newObject); // write your structure to object output stream...
                byte data_to_be_sent[] = baos.toByteArray (); // retrieving equivalent byte array...
                // send data...
                DatagramSocket s = new DatagramSocket ();
                System.out.println ("Sending ...");
                DatagramPacket packet = new DatagramPacket (data_to_be_sent, data_to_be_sent.length);
                packet.setAddress (InetAddress.getByName ("localhost"));
                packet.setPort (8888);
                s.send (packet);
            catch (Exception e)
                e.printStackTrace ();
    class YourStructure implements Serializable
         * Holds value of property shortField1.
        private short shortField1;
         * Holds value of property shortField2.
        private short shortField2;
         * Holds value of property shortField3.
        private short shortField3;
         * Holds value of property array.
        private byte[] array;
         * Getter for property shortField1.
         * @return Value of property shortField1.
        public short getShortField1 ()
            return this.shortField1;
         * Setter for property shortField1.
         * @param shortField1 New value of property shortField1.
        public void setShortField1 (short shortField1)
            this.shortField1 = shortField1;
         * Getter for property shortField2.
         * @return Value of property shortField2.
        public short getShortField2 ()
            return this.shortField2;
         * Setter for property shortField2.
         * @param shortField2 New value of property shortField2.
        public void setShortField2 (short shortField2)
            this.shortField2 = shortField2;
         * Getter for property shortField3.
         * @return Value of property shortField3.
        public short getShortField3 ()
            return this.shortField3;
         * Setter for property shortField3.
         * @param shortField3 New value of property shortField3.
        public void setShortField3 (short shortField3)
            this.shortField3 = shortField3;
         * Getter for property array.
         * @return Value of property array.
        public byte[] getArray ()
            return this.array;
         * Setter for property array.
         * @param array New value of property array.
        public void setArray (byte[] array)
            this.array = array;
        public String toString ()
            StringBuffer buffer = new StringBuffer ();
            buffer.append ("Short field 1 is ");
            buffer.append(this.getShortField1 ());
            buffer.append ("\nShort field 2 is ");
            buffer.append (this.getShortField2 ());
            buffer.append ("\nShort field 3 is ");
            buffer.append (this.getShortField3 ());
            buffer.append ("\nYour array field is ");
            for (int index = 0; index < this.getArray ().length; index++)
                buffer.append ("Index [" + index + "] = " + this.getArray () [index] + "\n");
            return buffer.toString ();
    class DatagramServerThread extends Thread
        protected DatagramSocket socket = null;
        public DatagramServerThread (String name) throws IOException
            super (name);
            socket = new DatagramSocket (8888);
        public void run ()
            try
                byte buffer [] = new byte [socket.getReceiveBufferSize ()];
                DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
                System.out.println ("Server is ready. Waiting for packet ...");
                socket.receive(packet); // waiting for packet ...
                System.out.println ("Packet received! : ");
                byte received_data[] = packet.getData ();
                ByteArrayInputStream bais = new ByteArrayInputStream (received_data); // Creating byte array input stream ..
                ObjectInputStream ois = new ObjectInputStream (bais); // Creting Object input stream
                Object readed_object = ois.readObject ();
                YourStructure your_original_object = (YourStructure)readed_object;
                System.out.println (your_original_object.toString ());
                System.out.println ("Exiting server thread. Bye");
                socket.close ();
            catch (Exception e)
                System.err.println ("Server error");
                e.printStackTrace ();
    }

  • How to invoke a class at run-time for primitive data types?

    Hi,
    I am trying to invoke classes at run-time.
    I am using Class.forName("className") for that where the "className" is also obtained at run-time .
    The problem I am getting is when the "className" is "int" or "char" etc. the call to Class.forName("int") etc. fails giving ClassNotFound error. It works fine for "className" is "java.lang.String" or "java.lang.Integer" etc.
    How can I correct this?
    thanks in advance-
    kg

    Hi,
    Thanks all for the valuable inputs.
    I have created a hashtable of primitive data types in the form of "int" as key and "Integer.TYPE" as the object in that element of the hashtable.
    Now there is another problem I am facing and that is of 'Casting at run-time'.
    Problem is there when the Database type is 'NUMBER' which returns me a "java.lang.BigDecimal" when I do a ResultSet.getObject("XXX") for that whereas the method in the javabean expects an "int" type.
    This causes "java.lang.IllegalArgumentException: argument type mismatch"
    So I want to cast it at runtime. How can I do it?
    Here is the code I am trying (which generates the above exception)
    public static void setBeanField(Class pCls,Object pObj,String pMethodName ,Object pColumnValue,Class
    pColumnTypeClass){
    try{
    if(pColumnValue!=null){
    Class[] paramTypes = new Class[]{pColumnTypeClass};
    Object[] args = new Object[]{pColumnValue};
    Method meth = pCls.getMethod(pMethodName,paramTypes);
    meth.invoke(pObj,args);
    }catch(Exception e){
    System.out.println("Exception in TestInrospection.setBeanField " + e);
    thanks in advance-
    kg

Maybe you are looking for

  • IF and SUBSTR in XML Publisher

    Hi I am developing a XML RTF template for a report. All I am trying to do is, if first 4 letters of the data of xml tag ITEM = 'Summ' then print a constant word 'Notes' <?if: xdofx:substr(ITEM,1,4)='Summ'?> Notes<?end if?> I have been trying hard. IF

  • Calling a Method in other Class

    I want to call a method in another class when an action is preformed can anyone suggest how I might do this??      addSquare.addActionListener(new ActionListener()                public void actionPerformed(ActionEvent e)      

  • Goods Movement Qty While Confirming the Order

    Hi Friends, While confirming the order The end user Will go to the goods movement screen and enter the actual consumed Qty (When all BOM components Are marked with automatic Back flush) For the components with 261 movement type and will enter the sto

  • Prd server restore/copy on different hardware

    Hi Everyone, Our Client has  PRD SERVER running ECC 6.0   . u2022 SAP Release and Basis Release ECC 6.0, Kernel 7.0, Sup. Package level 15. u2022 ORACLE 10G u2022 Operating System : Windows (2003) NT 5.2 Build 3790 SP2 u2022 Hardware Model and Vendor

  • Error on powershell: "Requested registry access is not allowed"

    Hi! Suddenly after reboot all runbooks fail on all .net activities. I tried even an empty powershell single activity, and that too fails with: "Requested registry access is not allowed" Please help! Egils Zonde from Technet