axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "FURTADO, Murray, GBM" <Murray.FURT...@rbos.com>
Subject Axis2-1.1.1 (& 1.2-RC2): StringIndexOutOfBoundsException in parse () method of Stub.InnerClass
Date Tue, 03 Apr 2007 16:08:33 GMT
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> ){
                  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
<mailto: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.com
www.rbsgc.com
www.rbsmarkets.com
***********************************************************************************

Mime
View raw message