• 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

Use a singleton for javax.xml.ws.Service instance

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone, I'm pretty new to WS and I need some help.
I have a jax-ws generated client for a ws. The easiest approach to call the client would be



But, rather then instantiate all the times the service class, I'm trying to understand if i can just put a single instance in a Singleton and use the same instance if Service to access the ws (calling each time the getPort method).
The code would look something like this:



Thanks in advance.

e
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

About your question on Web Service, I don't know. But about the singleton I can tell you that it won't work because you're trying to instantiate a no static field in a static bloc.

Use instend of :



Regards
 
Emilio Meadow
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I know..
I realize the small typo when I was already away from my pc.
Thanks anyway.

Back to the question, I've searched a lot and it seems that it's a very common question but unfortunately I couldn't find any definitive answer.
I think though that javax.xml.ws.Service seems to be made to be shared among many calls to the ws, in fact it has an enumeration of ports and a set of methods "getPort" that will retrive "compatible port" (from the javadoc).
Anyway I'm still looking for an answer..
 
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Emilio Meadow wrote:I know I know..
I realize the small typo when I was already away from my pc.
Thanks anyway.

Back to the question, I've searched a lot and it seems that it's a very common question but unfortunately I couldn't find any definitive answer.
I think though that javax.xml.ws.Service seems to be made to be shared among many calls to the ws, in fact it has an enumeration of ports and a set of methods "getPort" that will retrive "compatible port" (from the javadoc).
Anyway I'm still looking for an answer..



Did you try using the client?
 
Emilio Meadow
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Palak,
I'm sorry, what you mean by client? I use the .jar genereated by the wsimport tool. What else?
e
 
Palak Mathur
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Emilio Meadow wrote:Hi Palak,
I'm sorry, what you mean by client? I use the .jar genereated by the wsimport tool. What else?
e



You wrote the code with the singleton implementation or modified the code generated by the tool. Did you try to run that? Sorry, let me know if you are not able to understand my question. I will try to rephrase it again.
 
Emilio Meadow
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I got you.
I used the classes generated by the tool to write my code, this means the class and the interface were generated by wsimport.
 
reply
    Bookmark Topic Watch Topic
  • New Topic