1Z0-900 · Question #65
Which statement is true about Java methods that are exposed as Web Service operations by using JAX-WS API?
The correct answer is D. The @WebMethod annotation must exist. D is correct because @WebMethod is the annotation that marks a method for exposure as a Web Service operation in JAX-WS. Without it (or if exclude=true is set), the method is not published - it's the gating annotation for service operation exposure. Why the distractors are…
Question
Which statement is true about Java methods that are exposed as Web Service operations by using JAX-WS API?
Options
- AThe @WebResult annotation must exist.
- BMethod parameters and return types must be JAXB compatible.
- CMethod parameters must be declared by using @WebParam.
- DThe @WebMethod annotation must exist.
How the community answered
(15 responses)- C7% (1)
- D93% (14)
Explanation
D is correct because @WebMethod is the annotation that marks a method for exposure as a Web Service operation in JAX-WS. Without it (or if exclude=true is set), the method is not published - it's the gating annotation for service operation exposure.
Why the distractors are wrong:
- A -
@WebResultis optional; it merely customizes the name of the return value wrapper element in the WSDL. Omitting it is perfectly valid. - B - JAX-WS uses JAXB for serialization by default, but parameters and return types don't have to be explicitly JAXB-annotated - many standard Java types (
String, primitives, collections) are already JAXB-compatible without extra work, and the constraint isn't stated this absolutely. - C -
@WebParamis optional, used only to customize parameter names in the generated WSDL. Parameters work fine without it.
Memory tip: Think of @WebMethod as the doorbell - without it, the outside world can't ring your method. Everything else (@WebParam, @WebResult) is just labeling the doorbell, not installing it.
Topics
Community Discussion
No community discussion yet for this question.