This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

@WebMethod rules  RSS feed

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Those who are preparing for SCDJWS 5.0 Beta can help me out here :

I am trying to put together the rules which are there for @WebMethod

Scenario 1 : No WebMethod in any method


This would create a wsdl which has two operations <operation name="addNumbers"> and <operation name="addNumbers2">

Scenario 2 : WebMethod annotation in only one of the method


This would have only one operation <operation name="addNumbers">

Scenario 3 : One method with @WebMethod(exclude=true)


This would give only one operation <operation name="addNumbers2">

Any more rules for @WebMethod ?
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This thread is a bit old, but still very valuable. I think that there miss just one scenario which put all the four possibilities together:
 
Ranch Hand
Posts: 558
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Christian Nicoll wrote:This thread is a bit old, but still very valuable. I think that there miss just one scenario which put all the four possibilities together:




Please help me understand this annotation.

My initial understanding was, there is no explicit need to mention @WebMethod, in SEI, if we want to expose all the public methods as webservice methods. There is no need to use @WebMethod, if we are intending to use the default values.

How come the fourth method defined above not exposed as the service. Should the fourth method is logically same as exclude=false.
 
Rancher
Posts: 3516
34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Christian Nicoll wrote:This thread is a bit old, but still very valuable. I think that there miss just one scenario which put all the four possibilities together:



How about inheritance?

@WebMethod can exist also in superclass...

Which specification describes the behaviour?

Because JAX-WS runtimes behave inconsistently....
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently the JSR-181 specification went through some changes as we can see at WebService / WebMethod rules changed in latest spec -

The JSR-181 specification has a change that defines the rules for when a method should be exposed as a Web method.

--- JSR-181 v0.9.2 (Dec '04)
If the implementation bean does not implement a service endpoint
interface, it must include @WebMethod annotations on each method that is
to be exposed as a Web Service operation. More information on the
@WebMethod annotation may be found in section 5.2.

--- JSR-181 v1.0 (June '05)
If the implementation bean does not implement a service endpoint
interface, all public methods other than those inherited from
java.lang.Object will be exposed as Web Service operations. This
behavior can be overridden by using the WebMethod annotation to specify
explicitly those public methods that are to be exposed. If a WebMethod
annotation is present, only the methods to which it is applied are
exposed.



Regards,
Dan
 
Mikalai Zaikin
Rancher
Posts: 3516
34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dan Drillich wrote:Apparently the JSR-181 specification went through some changes as we can see at WebService / WebMethod rules changed in latest spec -

The JSR-181 specification has a change that defines the rules for when a method should be exposed as a Web method.

--- JSR-181 v0.9.2 (Dec '04)
If the implementation bean does not implement a service endpoint
interface, it must include @WebMethod annotations on each method that is
to be exposed as a Web Service operation. More information on the
@WebMethod annotation may be found in section 5.2.

--- JSR-181 v1.0 (June '05)
If the implementation bean does not implement a service endpoint
interface, all public methods other than those inherited from
java.lang.Object will be exposed as Web Service operations. This
behavior can be overridden by using the WebMethod annotation to specify
explicitly those public methods that are to be exposed. If a WebMethod
annotation is present, only the methods to which it is applied are
exposed.




Regards,
Dan



Well, I'm concerning that highlighted in red not true any more: With JAX-WS 2.2 implementation, all public methods are always exposed (unless attribute 'exclude=false'), even if I put @WebMethod on some public method.

Before, AFAK, there was a behaviour:
a) by default all public methods are exposed
b) if at least one @WebMethod annotation present, then only those methods exposed which have @WebMethod, and other public methods are not exposed.

New rule also violates JSR-250:


In addition to affecting the annotated class, class-level annotations may act as a
shorthand for member-level annotations. If a member carries a specific member-
level annotation, any annotations of the same type implied by a class-level
annotation are ignored. In other words, explicit member-level annotations have
priority over member-level annotations implied by a class-level annotation. For
example, a @WebService annotation on a class implies that all the public
method in the class that it is applied on are annotated with @WebMethod if there
is no @WebMethod annotation on any of the methods. However if there is a
@WebMethod annotation on any method then the @WebService does not imply
the presence of @WebMethod on the other public methods in the class.



Any comments ?

Best regards,
MZ
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, I would say that the best practice would be to place the @WebMethod annotation for all methods we would like to expose.

Any thoughts?

Regards,
Dan
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The quote from the JSR-181:


All of the methods on the service endpoint interface are mapped to WSDL operations,
regardless of whether they include a @WebMethod annotation.
A method MAY include a @WebMethod annotation to customize the mapping to WSDL,
but is not REQUIRED to do so.



JSR-181

Paragraph 3.2 Service Endpoint Interface
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!