• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Doubt regarding invocation of JAX-WS through java client code

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi! every body,

i am sharing a java client code from java web services up and running by MARTIN KALIN.I have few doubts related to web service invocation from this client code.
I would like to mention that I am using jdk 1.6 which as per to the book has got built in support for JAX-WS.
The web service being invoked has two operations:
1. First method in the service returns current DATE as String and takes nothing as an argument.
2. Second method returns a long vaue as time elapsed in milliseconds till now.


DOUBTS
I have not generated and kept any STUBS on my client end and still i am able to invoke the web service successfully.
How is instance of a class implementing TiimeServer interface getting created when their is no definition of the class implementing that interface on the client side.

how are soap messages getting created as i am not able to see any class or related artifact which can do so?

Please elaborate these points. I know this would be basic questions for experienced members in the forum but as i am a beginner please elaborate it.

I would request IVAN KRIZGAN as i found him more active in the forum among others to explain the fact.


Regards

Jolly



 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I would request IVAN KRIZGAN as i found him more active in the forum among others to explain the fact.


Haha, this must be the first time I get a personal request!
Also it is "Krizsan", not "Krizgan".

You have read this document, right? http://faq.javaranch.com/java/EaseUp

Later:
OK, I am back to try to answer your question:

Why don't you need any generated artifacts in the example you showed?
When you create the Service object on row 11 you provide two things:
a) An URL from which the WSDL of the service you want to invoke can be retrieved.
b) The fully qualified name of the WSDL <service> element representing the service you want to invoke.
What happens is something along these lines:
- The WSDL is retrieved.
- The <service> element in the WSDL which you want to invoke is looked up using the QName you provided.
- The <portType> element for the service is located, by first going to the WSDL <binding> element for the <service> in question and then locating the <portType> specified in the <binding> element.
- When you on line 14 retrieve the proxy for the service, a proxy is created using the provided interface.
- The methods in the provided interface are matched to the <operation> elements in the <portType> element retrieved in the above step.
- JAXB beans are generated for the request and response messages.
- The address of the web service is retrieved from the <service> element.
This is the address to which web service requests in the form of SOAP messages are sent to when the service is invoked.
- When you invoke a method on the proxy, like in line 16, the proxy populates appropriate JAXB bean and marshals it to XML and sends the request in a SOAP envelope to the address retrieved above.
- It also receives the response, unmarshals it, retrieves the return data and returns it to the invoker of the proxy.

I admit not having actually looked at any code that implements the above in JAX-WS, but the above should at least explain the principles.
Basically, the artifacts are created at runtime, instead of at the time when wsimport or wsgen is invoked. The difference is that they are disposed when the program shuts down and you never get to see the artifacts.
Reference:
https://jax-ws-architecture-document.dev.java.net/nonav/doc/com/sun/xml/ws/client/package-summary.html
Best wishes!
 
Jolly Tiwari
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ivan for the explaination.


The only point which raises question in my mind is

When you on line 14 retrieve the proxy for the service, a proxy is created using the provided interface.

how is the definition of the class implementing the end point interface getting created at client side in order to get an instance of that class which you call
a proxy??



Regards

Jolly
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again!
Sorry, I did not express myself carefully.
I should have written:
When you on line 14 retrieve the web service proxy, a class that will forward your requests to the web service is created. This class will implement the provided interface.
Hope this is more clear!
 
Jolly Tiwari
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

a class that will forward your requests to the web service is created

Ivan As i had mentioned in my very first message that i did not create any artifact using any tool and i was
able to access the web service with the same piece of client code mentioned in my first message.

So, what i understood from your last response is that proxy class implementing that SEI (interface) is created at runtime
and deleted by the run time environment , so we are not able to find those proxy classes.

please correct me if i am wrong.

Regards

Jolly
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, I'd say you got it right! :-)
A proxy class implementing the interface you supply is created at runtime.
Take a look at the java.lang.reflect.Proxy class in the JavaSE API - this is probably the mechanism used to create the runtime proxy.
Best wishes!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic