You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "FURTADO, Murray, GBM" <Mu...@rbos.com> on 2007/04/04 11:16:17 UTC

RE: Axis2-1.1.1 (& 1.2-RC2): StringIndexOutOfBoundsException in p arse () method of Stub.InnerClass

Does this mean that generated stub class code will have this change in it in
future releases?
 
Currently, if I make manual changes to my stub class to do this, each time
my web service interface changes, I will have to regenerate my stub and
apply the manual changes again?
 
Will this get folded in to the next release candidate?
 
Murray Furtado
Currency Options Sales Technology
RBS Global Banking and Markets 
280 Bishopsgate, London EC2M 4RB / 135 Bishopsgate, London EC2M 3TP 
 ( +44 207 085 0748 | * murray.furtado@rbos.com
<ma...@rbos.com> 
 

  _____  

From: Amila Suriarachchi [mailto:amilasuriarachchi@gmail.com] 
Sent: 04 April 2007 06:25
To: axis-user@ws.apache.org
Subject: Re: Axis2-1.1.1 (& 1.2-RC2): StringIndexOutOfBoundsException in
parse () method of Stub.InnerClass


It is normally assume that the type attribute value has a namespace prefix.
i.e ns1:complexTypeName. that is why we check for ':'
but if the complex type belongs to the default namespace the we may not have
the namespace prefix as you have mentioned. 
so I change the method as follows,
java.lang.String nsPrefix = null;
                    if (fullTypeName.indexOf(":") > -1){
                        nsPrefix =
fullTypeName.substring(0,fullTypeName.indexOf (":"));
                    }


On 4/3/07, FURTADO, Murray, GBM <Murray.FURTADO@rbos.com
<ma...@rbos.com> > wrote: 

Hi,
 
I have adb generated stub classes which are subclasses of a common parent
(XPortfolioProduct). In the static method to create the parent class object
I have code as follows:
 
 
       /**
        * static method to create the object
        * Precondition:  If this object is an element, the current or next
start element starts this object and any intervening reader events are
ignorable
        *                If this object is not an element, it is a complex
type and the reader is at the event just after the outer start element
        * Postcondition: If this object is an element, the reader is
positioned at its end element
        *                If this object is a complex type, the reader is
positioned at the end element of its outer element
        */
        public static XPortfolioProduct
parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
            XPortfolioProduct object = new XPortfolioProduct();
            int event;
            try {
                
                while (!reader.isStartElement() && !reader.isEndElement())
                    reader.next();
 
                
                if
(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type"
)!=null
<http://www.w3.org/2001/XMLSchema-instance%22,%22type%22%29%21=null> ){
                  java.lang.String fullTypeName =
reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> ",
                        "type");
                  if (fullTypeName!=null){
                    java.lang.String nsPrefix =
fullTypeName.substring(0,fullTypeName.indexOf(":"));    <--- String index
out of range: -1
                    nsPrefix = nsPrefix==null?"":nsPrefix;
 
                    java.lang.String type =
fullTypeName.substring(fullTypeName.indexOf(":")+1);
                    if (!"XPortfolioProduct".equals(type)){
                        //find namespace for the prefix
                        java.lang.String nsUri =
reader.getNamespaceContext().getNamespaceURI(nsPrefix);
                        return
(XPortfolioProduct)ExtensionMapper.getTypeObject(
                             nsUri,type,reader);
                      }
                  }
             }...
 
The fullTypeName = 'SubClassName'  and doesn't contain a colon, so a
StringIndexOutOfBoundsException is thrown.
 
Any idea why this is happening?
 
 
Murray Furtado
Currency Options Sales Technology
RBS Global Banking and Markets 
280 Bishopsgate, London EC2M 4RB / 135 Bishopsgate, London EC2M 3TP 
 (  +44 207 085 0748 | * murray.furtado@rbos.com
<ma...@rbos.com> 
 
****************************************************************************
*******
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered
Office: 36 St Andrew Square, Edinburgh EH2 2YB. 


Authorised and regulated by the Financial Services Authority 
 
This e-mail message is confidential and for use by the 
addressee only. If the message is received by anyone other 
than the addressee, please return the message to the sender 


by replying to it and then delete the message from your 
computer. Internet e-mails are not necessarily secure. The 
Royal Bank of Scotland plc does not accept responsibility for 
changes made to this message after it was sent. 



Whilst all reasonable care has been taken to avoid the 
transmission of viruses, it is the responsibility of the recipient to 
ensure that the onward transmission, opening or use of this 
message and any attachments will not adversely affect its 


systems or data. No responsibility is accepted by The 
Royal Bank of Scotland plc in this regard and the recipient should carry 
out such virus and other checks as it considers appropriate. 
Visit our websites at: 


www.rbs.com <http://www.rbs.com> 

www.rbsgc.com <http://www.rbsgc.com> 

www.rbsmarkets.com <http://www.rbsmarkets.com> 

****************************************************************************
*******




-- 
Amila Suriarachchi,
WSO2 Inc. 

Re: Axis2-1.1.1 (& 1.2-RC2): StringIndexOutOfBoundsException in p arse () method of Stub.InnerClass

Posted by Amila Suriarachchi <am...@gmail.com>.
On 4/4/07, FURTADO, Murray, GBM <Mu...@rbos.com> wrote:
>
>  Does this mean that generated stub class code will have this change in it
> in future releases?
>

yes.

Currently, if I make manual changes to my stub class to do this, each time
> my web service interface changes, I will have to regenerate my stub and
> apply the manual changes again?
>
> Will this get folded in to the next release candidate?
>

yes. even if you get a nightly build you can get this.
http://people.apache.org/dist/axis2/nightly/axis2-1.2-SNAPSHOT.zip

Murray Furtado
> Currency Options Sales Technology
> RBS Global Banking and Markets
> 280 Bishopsgate, London EC2M 4RB / 135 Bishopsgate, London EC2M 3TP
>  ( +44 207 085 0748 | * murray.furtado@rbos.com
>
>
>  ------------------------------
> *From:* Amila Suriarachchi [mailto:amilasuriarachchi@gmail.com]
> *Sent:* 04 April 2007 06:25
> *To:* axis-user@ws.apache.org
> *Subject:* Re: Axis2-1.1.1 (& 1.2-RC2): StringIndexOutOfBoundsException in
> parse () method of Stub.InnerClass
>
> It is normally assume that the type attribute value has a namespace
> prefix.
> i.e ns1:complexTypeName. that is why we check for ':'
> but if the complex type belongs to the default namespace the we may not
> have the namespace prefix as you have mentioned.
> so I change the method as follows,
> java.lang.String nsPrefix = null;
>                     if (fullTypeName.indexOf(":") > -1){
>                         nsPrefix = fullTypeName.substring(0,
> fullTypeName.indexOf (":"));
>                     }
>
> On 4/3/07, FURTADO, Murray, GBM <Mu...@rbos.com> wrote:
> >
> >  Hi,
> >
> > I have adb generated stub classes which are subclasses of a common
> > parent (XPortfolioProduct). In the static method to create the parent class
> > object I have code as follows:
> >
> >
> >        /**
> >         * static method to create the object
> >         * Precondition:  If this object is an element, the current or
> > next start element starts this object and any intervening reader events are
> > ignorable
> >         *                If this object is not an element, it is a
> > complex type and the reader is at the event just after the outer start
> > element
> >         * Postcondition: If this object is an element, the reader is
> > positioned at its end element
> >         *                If this object is a complex type, the reader is
> > positioned at the end element of its outer element
> >         */
> >         public static XPortfolioProduct parse(
> > javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
> >             XPortfolioProduct object = new XPortfolioProduct();
> >             int event;
> >             try {
> >
> >                 while (!reader.isStartElement() &&
> > !reader.isEndElement())
> >                     reader.next();
> >
> >
> >                 if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null
> > <http://www.w3.org/2001/XMLSchema-instance%22,%22type%22%29%21=null>){
> >                   java.lang.String fullTypeName =
> > reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance ",
> >                         "type");
> >                   if (fullTypeName!=null){
> > *                    java.lang.String nsPrefix = fullTypeName.substring
> > (0,fullTypeName.indexOf(":"));    <--- String index out of range: -1*
> >                     nsPrefix = nsPrefix==null?"":nsPrefix;
> >
> >                     java.lang.String type = fullTypeName.substring(
> > fullTypeName.indexOf(":")+1);
> >                     if (!"XPortfolioProduct".equals(type)){
> >                         //find namespace for the prefix
> >                         java.lang.String nsUri =
> > reader.getNamespaceContext().getNamespaceURI(nsPrefix);
> >                         return
> > (XPortfolioProduct)ExtensionMapper.getTypeObject(
> >                              nsUri,type,reader);
> >                       }
> >                   }
> >              }...
> >
> > The fullTypeName = 'SubClassName'  and doesn't contain a colon, so a
> > StringIndexOutOfBoundsException is thrown.
> >
> > Any idea why this is happening?
> >
> >
> >  Murray Furtado
> > Currency Options Sales Technology
> > RBS Global Banking and Markets
> > 280 Bishopsgate, London EC2M 4RB / 135 Bishopsgate, London EC2M 3TP
> >  (  +44 207 085 0748 | * murray.furtado@rbos.com
> >
> >
> > ***********************************************************************************
> > The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
> >
> > Authorised and regulated by the Financial Services Authority
> >
> > This e-mail message is confidential and for use by the
> > addressee only. If the message is received by anyone other
> > than the addressee, please return the message to the sender
> >
> > by replying to it and then delete the message from your
> > computer. Internet e-mails are not necessarily secure. The
> > Royal Bank of Scotland plc does not accept responsibility for
> > changes made to this message after it was sent.
> >
> >
> > Whilst all reasonable care has been taken to avoid the
> > transmission of viruses, it is the responsibility of the recipient to
> > ensure that the onward transmission, opening or use of this
> > message and any attachments will not adversely affect its
> >
> > systems or data. No responsibility is accepted by The
> > Royal Bank of Scotland plc in this regard and the recipient should carry
> > out such virus and other checks as it considers appropriate.
> > Visit our websites at:
> >
> > www.rbs.comwww.rbsgc.comwww.rbsmarkets.com
> > ***********************************************************************************
> >
> >
>
>
> --
> Amila Suriarachchi,
> WSO2 Inc.
>



-- 
Amila Suriarachchi,
WSO2 Inc.