Java service


How to write a java service to append string to stringList/string array in webmethods.


There is a public API service already.

1 Like

Hi Mahesh,

I have a service which takes key as input and returns property as output.
In the service if Key value has a space it does not return corresponding property.
How do i achieve this so that i can get corresponding property value.
Ex: If key is β€œa”, its returns property one
If key is β€œcity is” then it will not return any property.

Please advice.

Key value pair is stored in config value. Need to pass filepath and key and fetch the corresponding property value.

Now I see you are getting into details :slight_smile:

If you want to get the key-value from the custom properties file, I would suggest to explore PSUtillities package which must be available here.

Other options I would advise to store key-value pairs in Cache or Ehcache as it is support OOTB from wM v8.2 onwards. There are public API services which can be used to put and get the key-value pairs which does provide good performance and if you want a cluster aware support you can have Terracotta server too.

Let us know your options, if you still unable to find the java code to read the key-value we can help you out!

Thanks Mahesh.

I refereed PSUtilities and WMSamples package. The service available does not work if there is a space in the Key.
We need to modify so that it takes space into account and considers β€˜=’ as delimiter.
How do achieve this.
Please let me know your suggestion.


You can escape every thing in properties file with Java Unicode:

\u003d for =
\u0020 for whitespace


For eg. in your props file add key as below



As suggested earlier use cache to put and get key-value pairs.

Thanks Mahesh.

I did the same. Used escape char for space in property file.
I just wanted to understand if anything can be done in the code to accept space.

But now I went with escape char.

I would suggest you go with this now on the other hand as good practice avoid spaces or = sign while defining keys in props file.

At a later stage, you can move the whole properties file to the cache which requires a good design and coding in place.

Thanks a lot for your input Mahesh