Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Dynamically changing the name of a webservice to be called

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamically changing the name of a webservice to be called

    Hi,
    Does anyone know how to make a webservice to be called dynamic, meaning I have an application which needs to validate the content of a field. The validation which needs to be done however, depends on the name of the field. So I have a database which contains fieldnames and the related webservice like:
    - field A , service CheckA
    - field B , service CheckB

    The code I would like to have is one single line which calls the validation service depending on the fieldname.

    Eg. call validation

    where validation would be CheckA if I'm processing field A and CheckB if I'm processing field B. So the name of the webservice to be called is set during the execution of the program.

    Thanks

  2. #2
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    70
    My Mood
    Cool
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default Re: Dynamically changing the name of a webservice to be called

    I presume you want something like this:

    validate(field);

    And the validate method would validate the field depending on its type.

    The problem lies in that unless the fields are different types, I don't think you can do it. Consider two String fields. One is a date and the other a name. The validation code would be different for each.

    If the validation is simply for different types of primitives and objects you could do this.

    String type = ((Object)primitive).getClass().getSimpleType();

    You can then use that type value to call the appropriate validator. There are many ways to set this up.

    Regards,
    Jim

  3. #3
    Junior Member
    Join Date
    Sep 2018
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Dynamically changing the name of a webservice to be called

    If you are truly dynamically setting this, you should set the .Url field of instance of the proxy class you are calling.

    Setting the value in the .config file from within your program:

    Is a mess;

    Might not be read until the next application start.

    If it is only something that needs to be done once per installation, I'd agree with the other posters and use the .config file and the dynamic setting.

Similar Threads

  1. Replies: 1
    Last Post: September 2nd, 2014, 08:14 AM
  2. webservice
    By prabhat11 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 27th, 2013, 08:19 AM
  3. Dynamically changing icons of some nodes in a JTree
    By vishnu_knl in forum AWT / Java Swing
    Replies: 5
    Last Post: October 22nd, 2012, 09:05 AM
  4. Replies: 0
    Last Post: September 21st, 2012, 11:11 AM
  5. Replies: 5
    Last Post: January 9th, 2012, 01:36 PM