0

我想在不使用 pub.string.length (built in function) in web methods 的情况下查找给定字符串的长度。

 Ex:If we give name "abcdef" i want result like 6 .
4

2 回答 2

1

您可以编写自己的 java 服务,但这对我来说听起来是多余的。

这是一个(尚未测试的)代码示例:

public static final void checkStringSize(IData pipeline)
        throws ServiceException {

    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String  inputString = IDataUtil.getString( pipelineCursor, "inputString" );
    pipelineCursor.destroy();

    long length = -1;
    length = inputString.length();

    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    IDataUtil.put( pipelineCursor_1, "length", ""+length );
    pipelineCursor_1.destroy();
}
于 2016-10-19T00:47:35.147 回答
-2

您可以使用 pub.string:substring 手动计算字符串的长度,直到出现错误。我不推荐这个——它不优雅,可能很慢,而且它仍然使用来自 pub.string 的函数,你似乎在避免使用它。无论如何,这是一种方法,单击链接查看图像。

webMethods 代码示例 - https://i.stack.imgur.com/FE9oU.jpg

只需确保输入字符串不能为空 - 否则子字符串不会抛出错误,并且会出现无限循环。

于 2016-10-19T01:27:05.223 回答