Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Generating stubs for accessing webservices in Eclipse JDE Plugin

How are the _qname_urn_PruebaWSWsd_obtenerArticulo, _type_obtenerArticulo and _type_obtenerArticuloResponse variables being initialized?  What happens in the _prepOperation call?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 88
Registered: ‎09-25-2008
My Device: Not Specified

Re: Generating stubs for accessing webservices in Eclipse JDE Plugin

Im going to post all the code:

 

// This class was generated by 172 StubGenerator.
// Contents subject to change without notice.
// @generated

package stub;

import java.util.Enumeration;
import java.util.Hashtable;

import javax.microedition.xml.rpc.ComplexType;
import javax.microedition.xml.rpc.Element;
import javax.microedition.xml.rpc.Operation;
import javax.microedition.xml.rpc.Type;
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;

public class PruebaWSVi_Document_Stub implements stub.PruebaWSVi_Document, javax.xml.rpc.Stub {
     private Hashtable properties;


    public PruebaWSVi_Document_Stub() {
        properties = new Hashtable();
        properties.put(ENDPOINT_ADDRESS_PROPERTY,new String("http://esdgre202948:50000/PruebaWS/Config1?style=document"));

       
//        _propertyNames = new String[] {ENDPOINT_ADDRESS_PROPERTY};
//        _propertyValues = new Object[] {"http://esdgre202948:50000/PruebaWS/Config1?style=document"};
    }

     public void _setProperty(String name, Object value)
        {
        properties.put(name,value);
        }

        /**
         * Gets the value of a specific configuration property.
         */
        public Object _getProperty(String value)
        {
            if (ENDPOINT_ADDRESS_PROPERTY.equals(value) ||
                USERNAME_PROPERTY.equals(value) ||
                PASSWORD_PROPERTY.equals(value))
            {
                return null;
            }

            if (SESSION_MAINTAIN_PROPERTY.equals(value))
            {
                return new Boolean(false);
            }

            if (properties.containsKey(value))
            {
                return properties.get(value);
            }

            throw new JAXRPCException("Unknown property: "+value);
        }




    //
    //  Begin user methods
    //

    public stub.Articulo obtenerArticulo(long id) throws java.rmi.RemoteException {
        // Copy the incoming values into an Object array if needed.
        Object[] inputObject = new Object[1];       
        inputObject[0] = String.valueOf(id);

       
        Operation op = Operation.newInstance(_qname_urn_PruebaWSWsd_obtenerArticulo, _type_obtenerArticulo, _type_obtenerArticuloResponse);
        prepareOperation(op);
        op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "");       
        Object resultObj;
       
        try {
            resultObj = op.invoke(inputObject);
        } catch (JAXRPCException e) {
            Throwable cause = e.getLinkedCause();
            if (cause instanceof java.rmi.RemoteException) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }
        stub.Articulo result;
        // Convert the result into the right Java type.
        // Unwrapped return value
        Object[] responseObj = (Object[]) ((Object[])resultObj)[0];
        if (responseObj == null) {
            result = null;
        } else {
            result = new stub.Articulo();
            long a_long;
            Object idObj = responseObj[0];
            a_long = ((java.lang.Long)idObj).longValue();
            result.setId(a_long);
            java.lang.String string;
            Object nombreObj = responseObj[1];
            string = (java.lang.String)nombreObj;
            result.setNombre(string);
            java.lang.String string2;
            Object referenciaObj = responseObj[2];
            string2 = (java.lang.String)referenciaObj;
            result.setReferencia(string2);
        }
        return result;
    }

 

 

 

Developer
Posts: 88
Registered: ‎09-25-2008
My Device: Not Specified

Re: Generating stubs for accessing webservices in Eclipse JDE Plugin

I
    public stub.ArrayOfArticulo obtenerListaArticulos(int parametro) throws java.rmi.RemoteException {
        // Copy the incoming values into an Object array if needed.
        Object[] inputObject = new Object[1];
        inputObject[0] = new java.lang.Integer(parametro);

        Operation op = Operation.newInstance(_qname_urn_PruebaWSWsd_obtenerListaArticulos, _type_obtenerListaArticulos, _type_obtenerListaArticulosResponse);
        prepareOperation(op);
        op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "");
        Object resultObj;
        try {
            resultObj = op.invoke(inputObject);
        } catch (JAXRPCException e) {
            Throwable cause = e.getLinkedCause();
            if (cause instanceof java.rmi.RemoteException) {
                throw (java.rmi.RemoteException) cause;
            }
            throw e;
        }
        stub.ArrayOfArticulo result;
        // Convert the result into the right Java type.
        // Unwrapped return value
        Object[] responseObj = (Object[]) ((Object[])resultObj)[0];
        if (responseObj == null) {
            result = null;
        } else {
            result = new stub.ArrayOfArticulo();
            stub.Articulo[] articuloArray;
            Object[] articuloObj = (Object[]) responseObj[0];
            if (articuloObj == null) {
                articuloArray = null;
            } else {
                int articuloArraySize = articuloObj.length;
                articuloArray = new stub.Articulo[articuloArraySize];
                for (int articuloArrayIndex = 0;
                    articuloArrayIndex < articuloArraySize;
                    ++articuloArrayIndex) {
                    if (articuloObj[articuloArrayIndex] == null) {
                        articuloArray[articuloArrayIndex] = null;
                    } else {
                        articuloArray[articuloArrayIndex] = new stub.Articulo();
                        long a_long;
                        Object idObj = ((Object[])articuloObj[articuloArrayIndex])[0];
                        a_long = ((java.lang.Long)idObj).longValue();
                        articuloArray[articuloArrayIndex].setId(a_long);
                        java.lang.String string;
                        Object nombreObj = ((Object[])articuloObj[articuloArrayIndex])[1];
                        string = (java.lang.String)nombreObj;
                        articuloArray[articuloArrayIndex].setNombre(string);
                        java.lang.String string2;
                        Object referenciaObj = ((Object[])articuloObj[articuloArrayIndex])[2];
                        string2 = (java.lang.String)referenciaObj;
                        articuloArray[articuloArrayIndex].setReferencia(string2);
                    }
                }
            }
            result.setArticulo(articuloArray);
        }
        return result;
    }
    //
    //  End user methods
    //

    protected static final QName _qname_Response = new QName("urnSmiley TongueruebaWSVi", "Response");
    protected static final QName _qname_id = new QName("urnSmiley TongueruebaWSVi", "id");
    protected static final QName _qname_obtenerArticulo = new QName("urnSmiley TongueruebaWSVi", "obtenerArticulo");
    protected static final QName _qname_obtenerArticuloResponse = new QName("urnSmiley TongueruebaWSVi", "obtenerArticuloResponse");
    protected static final QName _qname_obtenerListaArticulos = new QName("urnSmiley TongueruebaWSVi", "obtenerListaArticulos");
    protected static final QName _qname_obtenerListaArticulosResponse = new QName("urnSmiley TongueruebaWSVi", "obtenerListaArticulosResponse");
    protected static final QName _qname_parametro = new QName("urnSmiley TongueruebaWSVi", "parametro");
    protected static final QName _qname_urn_PruebaWSWsd_obtenerArticulo = new QName("urnSmiley TongueruebaWSWsd", "obtenerArticulo");
    protected static final QName _qname_urn_PruebaWSWsd_obtenerListaArticulos = new QName("urnSmiley TongueruebaWSWsd", "obtenerListaArticulos");
    protected static final QName _qname_Articulo = new QName("urn:dto", "Articulo");
    protected static final QName _qname_urn_dto_id = new QName("urn:dto", "id");
    protected static final QName _qname_nombre = new QName("urn:dto", "nombre");
    protected static final QName _qname_referencia = new QName("urn:dto", "referencia");
    protected static final Element _type_obtenerArticulo;
    protected static final Element _type_obtenerArticuloResponse;
    protected static final Element _type_obtenerListaArticulos;
    protected static final Element _type_obtenerListaArticulosResponse;
    static {
        // Create all of the Type's that this stub uses, once.
        Element _type_id;
        _type_id = new Element(_qname_id, Type.LONG);
        ComplexType _complexType_obtenerArticulo;
        _complexType_obtenerArticulo = new ComplexType();
        _complexType_obtenerArticulo.elements = new Element[1];
        _complexType_obtenerArticulo.elements[0] = _type_id;
        _type_obtenerArticulo = new Element(_qname_obtenerArticulo, _complexType_obtenerArticulo);
        Element _type_id2;
        _type_id2 = new Element(_qname_urn_dto_id, Type.LONG);
        Element _type_nombre;
        _type_nombre = new Element(_qname_nombre, Type.STRING, 0, 1, true);
        Element _type_referencia;
        _type_referencia = new Element(_qname_referencia, Type.STRING, 0, 1, true);
        ComplexType _complexType_articulo;
        _complexType_articulo = new ComplexType();
        _complexType_articulo.elements = new Element[3];
        _complexType_articulo.elements[0] = _type_id2;
        _complexType_articulo.elements[1] = _type_nombre;
        _complexType_articulo.elements[2] = _type_referencia;
        Element _type_Response;
        _type_Response = new Element(_qname_Response, _complexType_articulo, 1, 1, true);
        ComplexType _complexType_obtenerArticuloResponse;
        _complexType_obtenerArticuloResponse = new ComplexType();
        _complexType_obtenerArticuloResponse.elements = new Element[1];
        _complexType_obtenerArticuloResponse.elements[0] = _type_Response;
        _type_obtenerArticuloResponse = new Element(_qname_obtenerArticuloResponse, _complexType_obtenerArticuloResponse);
        Element _type_parametro;
        _type_parametro = new Element(_qname_parametro, Type.INT);
        ComplexType _complexType_obtenerListaArticulos;
        _complexType_obtenerListaArticulos = new ComplexType();
        _complexType_obtenerListaArticulos.elements = new Element[1];
        _complexType_obtenerListaArticulos.elements[0] = _type_parametro;
        _type_obtenerListaArticulos = new Element(_qname_obtenerListaArticulos, _complexType_obtenerListaArticulos);
        Element _type_Articulo;
        _type_Articulo = new Element(_qname_Articulo, _complexType_articulo, 0, -1, true);
        ComplexType _complexType_arrayOfArticulo;
        _complexType_arrayOfArticulo = new ComplexType();
        _complexType_arrayOfArticulo.elements = new Element[1];
        _complexType_arrayOfArticulo.elements[0] = _type_Articulo;
        Element _type_Response2;
        _type_Response2 = new Element(_qname_Response, _complexType_arrayOfArticulo, 1, 1, true);
        ComplexType _complexType_obtenerListaArticulosResponse;
        _complexType_obtenerListaArticulosResponse = new ComplexType();
        _complexType_obtenerListaArticulosResponse.elements = new Element[1];
        _complexType_obtenerListaArticulosResponse.elements[0] = _type_Response2;
        _type_obtenerListaArticulosResponse = new Element(_qname_obtenerListaArticulosResponse, _complexType_obtenerListaArticulosResponse);
    }
    protected void prepareOperation(Operation oper)
    {
        Enumeration names = properties.keys();
        Object key, val = null;

        if (names == null) return;

        while(names.hasMoreElements())
        {
            key = names.nextElement();
            val = properties.get(key);

            if (key instanceof String && val != null)
            {
                oper.setProperty((String)key,val.toString());
            }
        }
    }


}

BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Generating stubs for accessing webservices in Eclipse JDE Plugin

What BlackBerry model and handheld software version are you testing with?  You can see this under Options, About on the BlackBerry.  Please verify if this occurs with any web service call, or just this particular one. 

 

Are you seeing this in the BlackBerry Simulator and on a real device, or just one or the other?  If you are testing on a real BlackBerry, do you receive a prompt from the firewall to allow the connection when you first attempt to connect to the web service?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 88
Registered: ‎09-25-2008
My Device: Not Specified

Re: Generating stubs for accessing webservices in Eclipse JDE Plugin

Im working on the simulator. At the MDS console I receive this:

 

 <2008-09-30 11:41:28.997 CEST>:[230]:<MDS-CS_MDS>:<DEBUG>:<LAYER = IPPP, EVENT =
 Receiving, TAG = -853738808, DEVICEPIN = 2100000a, VERSION = 16, CONNECTIONID =
 462402075, SEQUENCE = 0, TYPE = NOTIFY-REQUEST, CONNECTIONHANDLER = httpc, PROT
OCOL = TCP, PARAMETERS = [esdgre202948:50000], SIZE = 0>
<2008-09-30 11:41:28.997 CEST>:[231]:<MDS-CS_MDS>:<DEBUG>:<LAYER = IPPP, EVENT =
 CreatedReceivingQueue, DEVICEPIN:CONNECTIONID = 2100000a:462402075, ReceivingQu
eueSize = 1>
<2008-09-30 11:41:28.997 CEST>:[232]:<MDS-CS_MDS>:<DEBUG>:<LAYER = IPPP, EVENT =
 StartExecuting, TAG = -853738808, DEVICEPIN = 2100000a, VERSION = 16, CONNECTIO
NID = 462402075, SEQUENCE = 0, TYPE = NOTIFY-REQUEST, CONNECTIONHANDLER = httpc,
 PROTOCOL = TCP, PARAMETERS = [esdgre202948:50000], SIZE = 0>
<2008-09-30 11:41:28.997 CEST>:[233]:<MDS-CS_MDS>:<DEBUG>:<LAYER = SCM, EVENT =
Available threads in DefaultJobPool = 9 running JobRunner: DefaultJobRunner-5>
<2008-09-30 11:41:28.997 CEST>:[234]:<MDS-CS_MDS>:<DEBUG>:<LAYER = IPPP, EVENT =
 EndExecuting, TAG = -853738808, DEVICEPIN = 2100000a, VERSION = 16, CONNECTIONI
D = 462402075, SEQUENCE = 0, TYPE = NOTIFY-REQUEST, CONNECTIONHANDLER = httpc, P
ROTOCOL = TCP, PARAMETERS = [esdgre202948:50000], SIZE = 0>

Highlighted
Developer
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Re: Generating stubs for accessing webservices in Eclipse JDE Plugin

Hi Sickned,

Were you able to find a resolution for the "java.lang.StringIndexOutOfBoundsException: Index 0 >= 0"  exception?

Even I get the same exception at resultObj = op.invoke(inputObject).

I generated the stubs using WTK2.5.

 

Please let me know if this is solvable!