• 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 (value= ...) vs @WebServiceRef (type=...)

 
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone explain the difference between
@WebServiceRef(value=.....) and @WebServiceRef(type = ...) ?
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Himai Minh wrote:Can someone explain the difference between
@WebServiceRef(value=.....) and @WebServiceRef(type = ...) ?



There are two uses to the WebServiceRef annotation:

  • 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.
  • 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.


  • There're code examples too in the JAX-WS 2.2 spec, see section 7.9.1
     
    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
    I have a specific question from MZ's notes :


    However, this option is wrong because we are injecting the SEI and the value=CatalogService.class is missing.
    But according to the definition, type can refer to the SIB class. I don't understand why this option is wrong.
    That is why I raise this question what is the difference between value / type attribute in @WebServiceRef.
     
    a sarkar
    Ranch Hand
    Posts: 93
    • Likes 2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Himai Minh wrote:I have a specific question from MZ's notes :
    However, this option is wrong because we are injecting the SEI and the value=CatalogService.class is missing.


    Exactly as the 2nd point above says.

    Himai Minh wrote:I have a specific question from MZ's notes :
    But according to the definition, type can refer to the SIB class. I don't understand why this option is wrong.


    That's never said in the spec, you're reading b/w the lines. If you inject on a field of type SEI, and the type can be inferred from the field (in this case 'Catalog'), you don't need to specify type. Even if you do, the type must be the SEI class, not the SIB class. The code you've quoted is wrong because it violates that; it'd be right if the annotation just used value=CatalogService.class instead of type, or if it used type=Catalog.class and value=CatalogService.class.

    IMHO, the best way to clarify these doubts is to deploy the code. If it fails, make changes after reading the spec and deploy again.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic