nerdexam
Oracle

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…

Implement SOAP Services by Using JAX-WS and JAXB APIs

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)
  • C
    7% (1)
  • D
    93% (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 - @WebResult is 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 - @WebParam is 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

#JAX-WS#@WebMethod annotation#Web service operations#SOAP metadata

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice