Why sometimes, we inject a service reference like this:
private CatalogService catalogService ; //where CatalogService is a Service
@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?
Joined: Jul 29, 2012
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.
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).
Joined: Jul 29, 2012
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
private CatalogService service
What is the difference between these two examples?
Creator of Enthuware JWS+ V6
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):
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: @WebServiceRef(type=...) vs @WebServiceRef