1

I have class:

@WebServiceClient(name = "Test", wsdlLocation = ????)
public class WSSerfvice
    extends Service

To wsdlLocation I need to set variable, value of the variable will set by case. But my wsdlLocation ask my for a constant, by I don't know for sure which value I will have to set to wsdlLocation

I have Global class wher I set wsdlLocation for class above to set ???:

        String wsdlLocation;
        if(env.toLowerCase().equals("case1")) {
            wsdlLocation = "case1"
        } else (env.toLowerCase().equals("case2")) {
            wsdlLocation = "case2"
        } 

If I make wsdlLocation final compile exception.

How can I set variable to my ???? in annotation

java_user
  • 929
  • 4
  • 16
  • 39
  • [Same issue here](http://stackoverflow.com/questions/4455195/how-to-avoid-the-need-to-specify-the-wsdl-location-in-a-cxf-or-jax-ws-generated) - solved using cxf-codegen-plugin and "classpath:wsdl/FooService.wsdl" as wsdlLocation value. – alexk Oct 28 '15 at 13:12

1 Answers1

0

It seems not to be possible to modify constant field value in runtime, because it was inlined during compilation. Even reflection won't help.

For your case, IMO, it is preferrable, to set wsdlLocation to the relative path, pointing to the wsdl file in your classpath. In that case, you are able to provide different wsdl files, according to your environment. You can find a number of examples, how it could be done for your web service implementation.

Stanislav
  • 27,441
  • 9
  • 87
  • 82