substring

Given an ‘n’ character string, the pub.string:substring service in webMethods returns an empty string when I ask for substring with beginIndex=n and endIndex>n … shouldn’t this be giving me a StringIndexOutOfBoundsException ???

for beginIndex=(n+1) and onward it gives StringIndexOutOfBounds … which is fine.

Could someone please explain if this is the programmed behavior of this service and if so what is the logic in doing so?

Thanks

Hi,

Yes, if end_index is greater then string.length then end_index is ignored. I agree with you that it should instead through an exception.

The service seudo code goes like this

if (begin_index == null || begin_index.length == 0 ) then
begin_index = 0

if (end_index == null || end_index.length == 0 || end_index.length > string.length)
then
return (string.subString(begin_index)
else
return (string.subString(begin_index, end_index))

Ram Challuri

Its just the way it is in wM, I guess. Will have to learn and live with it.

That’s the way it is in Integration Server. How it is in other products from the company named webMethods may vary…

Nice one Reamon.