• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@WebServiceRef(type=...) vs @WebServiceRef

 
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why sometimes, we inject a service reference like this:
@WebServiceRef
private CatalogService catalogService ; //where CatalogService is a Service

or
@WebServiceRef (type=Catalog.class) //where Catalog is SEI
private CatalogService catalogService;

?

What is the different between them? Why sometimes we need type parameter and sometimes we don't need the type parameter?
 
Himai Minh
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me rephrase my question. Actually, I want to ask what is the purpose to use type parameter for @WebServiceRef (type=...)? I read Ivan's note and Java SOA Cookbook, but I still don't understand why.
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read the JAX-WS 2.x spec on this topic?

There are two uses to the WebServiceRef annotation:
1. To define a reference whose type is a generated service class. In this case, the type and value element will both refer to the generated service class type. Moreover, if the reference type can be inferred by the field/method declaration the annotation is applied to, the type and value elements MAY have the default value (Object.class, that is). If the type cannot be inferred, then at least the type element MUST be present with a non-default value.
2. To define a reference whose type is a SEI. In this case, the type element MAY be present with its default value if the type of the reference can be inferred from the annotated field/method declaration, but the value element MUST always be present and refer to a generated service class type (a subtypeof javax.xml.ws.Service).



Regards,
Frits
 
Himai Minh
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. I read these two definition from Java SOA Cookbook.
What is meant by if "type is not inferred"?
I can use MZ's notes' example:

@WebServiceRef (type =Catalog.class) //where Catalog is the SEI
private CatalogService service ; //where CatalogService is the generated Service

or

@WebServiceRef
private CatalogService service

What is the difference between these two examples?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no difference between those examples: the type of the reference (i.e. CatalogService) can be inferred from the instance variable "service" (which is of type CatalogService). The type parameter can be left out.

An example where the type cannot be inferred (because there is no instance variable):

Regards,
Frits
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic