This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Calculator example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Calculator example" Watch "Calculator example" New topic
Author

Calculator example

nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
I am trying to run calculator example from Ivan's note. i got following wsdl generated but when i try to access in browser
http://localhost:8080/CalculatorWebService/?wsdl i get error on page 404 error. any help will be appreciated.


Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Have you deployed the project successfully? Check the GlassFish logs to see if there were any errors during deployment.
Have you changed the project name to something else? If it is not CalculatorWebService, then the URL will also be changed.
If you do not succeed, please supply further details in order for me to be able to find a solution.
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Importa stuff i want to point that as per tutorial i have to get sun-web.xml which i don't, I use jboss as application server with eclipse.

I have CalculatorWebService.war deployed

structure is like this
WEB-inf and META-inf top folders
and inside webinf i have
--wsdl(folder)
|---- CalculatorService.wsdl
|----CalculatorService_schema1.xsd
--classes(folder)
|----com.ivan.Calculator.class(this is inside com.ivan.javax package)

|--- com.ivan.javax.Add and AddResponse
--web.xml
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
I got that example working in jboss. i mean i can see wsdl but i don't have client yet but i ll try that later. I copied jaxws-rt.2.1.3.jar,stax-ex-1.2.jar,streambuffer-0.8.jar and most importantly hand crafted sun-jaxws.xml.

Thanks for your help IVAN.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
If you, or someone else, are using the Metro web service stack, regardless of the container it runs in, then the sunjaxws.xml deployment descriptor must be present.
More information on this file, straight from the horse's mouth (so to speak), can be found here: https://metro.dev.java.net/guide/Deploying_Metro_endpoint.html#Using_sun_jaxws_xml

I notice that the instructions in my study notes are not entirely clear on this subject, I will update them. Thanks for bringing this issue to my attention!
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Hey Ivan,

One more stupid question, when i run build file which has utility of "wsgen". Does it suppose to generate "service and other artifiacts classes? i was able to client using eclipse but still i want to understand that.

Thanks
Nitin
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
The wsgen tool generates, from an annotated endpoint implementation class, artifacts for a web service and client implementation.
Artifacts are, for instance, a WSDL, JAXB bean classes, source and binary code.
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Here is my example of Calculator.java on running wsgen i didn't got service class. is that looks fishy though i modified this class a bit but i ll definitly try your example once again. Any help will be appreciate. thank

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
What you have enclosed IS the endpoint implementation class, which implements the service.
The wsgen tool will not generate a service class, since it already exists.
If you read page 153 in my study notes, you will find a listing of the artifacts that are generated by wsgen:
When running the above Ant script, the following files will be produced:
• Add.java
JAXB bean holding request data.
• AddResponse.java
JAXB bean holding response data.
• CalculatorService_schema1.xsd
XML schema defining elements wrapping request and response data in their XML form.
• CalculatorService.wsdl
The WSDL document of the Calculator service.

Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Yes i got all the artifiacts which you have mentioned except there is no "CalculatorService( i don't remember the name for now)". So another question What will be my endpoint in this case.

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Your endpoint implementation class will, as before, be the class you have written yourself and annotated with @WebService.
Actually, it was I that wrote it, but it is OK if you pretend it was you...
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Yes it is your example let me put my question another way. My question about page "161" which says CalculatorService will be automatcially generated which extends service class but i don't have that class?

How i will get "CalculatorService()"

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Note how "Service" is written with a capital S and in italics, this indicates that this is a class name.
The Service class extended is the javax.xml.ws.Service class in the Java API.
In addition, slightly below the text you quoted, there is the following text:
For detailed instructions on how to create a static standalone JAX-WS web service client, from
which the above code fragment was taken, please refer to the section Static Clients below!

You can click the text "Static Client" and you will be taken to the section that describes how to generate static client artifacts, such as the CalculatorService class.
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
I understood your point completely and my question was about that "Script" suppose to generate "CalculatorService" class. Anywayss i will figure it out thanks for your time and support.
 
Consider Paul's rocket mass heater.
 
subject: Calculator example
 
Similar Threads
Query regarding RPC/Document Style,WSGEN and WSIMPORT
how to switch on wsdl 2.0?
How to access GlassFish's web service testing facility
MTOM example
Proper way to define a fault in a WSDL