Results 1 to 6 of 6
Thread: @WebServiceClient Annotation
- 05-13-2016, 04:56 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 14
- Rep Power
- 0
@WebServiceClient Annotation
Hi all,
I have a web service client code with Annotation like the following, as you can see the web service IP ( 192.168.31.229 ) is hard coded, and it appears in three places in the code. I need to update code and compile it again when the IP has changed . now I am trying to store the IP in a configuration file and read the IP from it when the application started.
My question is:
do I need to replace the IP in the @WebServiceClient annotation? if yes, how to do it? Thanks a lot! ----Yhqian
@WebServiceClient(name = "TelWebServiceImplService", targetNamespace = "http://impl.service.bsi.com/", wsdlLocation = "http://192.168.31.229:8888/SCSERC_CHK/ws/telWebService?wsdl")
public class TelWebServiceImplService extends Service {
.........................
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.ictbox.acc.trigger.ggxx.TelWebServiceImplServi ce.class
.getResource(".");
url = new URL(baseUrl,
"http://192.168.31.229:8888/SCSERC_CHK/ws/telWebService?wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'http://192.168.31.229:8888/SCSERC_CHK/ws/telWebService?wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
TELWEBSERVICEIMPLSERVICE_WSDL_LOCATION = url;
}
.........................
}
- 05-13-2016, 10:26 AM #2
Re: @WebServiceClient Annotation
If the value is a String, then it must be a compile time constant. You can't have dynamic String values in annotations.
See also, the tough read: Chapter*9.*Interfaces"It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013
- 05-13-2016, 10:35 AM #3
Member
- Join Date
- Feb 2009
- Posts
- 14
- Rep Power
- 0
Re: @WebServiceClient Annotation
you said :You can't have dynamic String values in annotations
In what condition we can have dynamic values in annotations?
- 05-13-2016, 10:54 AM #4
Member
- Join Date
- Feb 2009
- Posts
- 14
- Rep Power
- 0
Re: @WebServiceClient Annotation
- 05-13-2016, 11:01 AM #5
Re: @WebServiceClient Annotation
None.
The spec says:
T is not an array type, and the type of V is assignment compatible (§5.2) with T, and:
- If T is a primitive type or String, then V is a constant expression (§15.28).
- If T is Class or an invocation of Class (§4.5), then V is a class literal (§15.8.2).
- If T is an enum type (§8.9), then V is an enum constant (§8.9.1).
- V is not null.
Java Code:@WebServiceClient(name = "TelWebServiceImplService", targetNamespace = "http://impl.service.bsi.com/", wsdlLocation = "http://192.168.31.229:8888/SCSERC_CHK/ws/telWebService?wsdl")
- If it's a primitive, then the value must be a literal, like 1 or true, or MyClass.MY_INT_CONSTANT
- If it's a Class, then the value must be a class literal in the form of String.class, MyObject.class, etc
- If it's an enum, then the value must be an enum, Directions.WEST, Directions.NORTH, whatever enum you have...
- and the value can't be null, so this is illegal: wsdlLocation=null"It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013
- 05-13-2016, 11:03 AM #6
Re: @WebServiceClient Annotation
"It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013
Similar Threads
-
annotation error
By simar in forum New To JavaReplies: 11Last Post: 09-15-2014, 11:21 AM -
annotation help
By javastuden in forum Advanced JavaReplies: 0Last Post: 01-07-2013, 11:37 AM -
Use of @Before and @After annotation with example..
By dhavalthakor28 in forum StrutsReplies: 4Last Post: 09-07-2012, 05:38 PM -
what is annotation? what is the use?
By java_no1 in forum New To JavaReplies: 2Last Post: 06-03-2011, 04:45 PM
Bookmarks