Sanjay Singh

Ranch Hand
+ Follow
since Mar 02, 2006
Sanjay likes ...
Hibernate Java Spring
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Sanjay Singh

Hi Frits,
Today again I deployed the war and it worked. I can see the wsdl & tester URL for the deployed war. Not sure what was the problem with earlier deployment as I haven't done any code or config changes.
Thanks for your help and prompt reply.
Note: I am using the glassfish 4.0.

Regards,
Sanjay
Hi Frist,
I checked the console and I can see the message as you mentioned:

[2013-10-14T19:36:07.904+0530] [glassfish 4.0] [INFO] [AS-WEB-GLUE-00172] [javax.enterprise.web] [tid: _ThreadID=82 _ThreadName=AutoDeployer] [timeMillis: 1381759567904] [levelValue: 800] [[ Loading application [webservice2] at [/webservice2]]]



But as I had mentioned in my previous msg that I can access the wsdl with url http://localhost:8080/webservice2/team?wsdl only when I have web.xml & sun-jaxws.xml configured. But let's say I only bundle the Teams class in a WAR and deploy then will glassfish will be able to deploy it as a webservice automatically as mentioned in the Java Webservice Up & Running book. The book says we can access with URL: http://localhost:8080/webservice2/TeamsService?wsdl which I am not able to access it after deploying without any deployment files.
Hi Frist,
The context root of my web-app is "webservice2" (have deployed as webservice2.war in glassfish). When I try to access the WSDL for Teams service (as mentioned in below code) with URL http://localhost:8080/webservice2/TeamsService?wsdl, it doesn't come up and gives 404 error.
Hi,
I am trying to deploy the JAX-WS Webservice on glassfish as given in the up & running example. I created the simple webservice with with @WebService annotation and packaged it as WAR and deployed in glassfish. I can see that it got deployed successfully but when I try to access the wsdl url, as mentioned in the book, it doesn't come up. It gives resource not found error. The example code:


If I add web.xml and sun-jaxws.xml with the WAR and configure it as following then I am able to access the wsdl:
web.xml:



sun-jaxws.xml:

Now I can access the wsdl using: http://localhost:8080/webservice2/team?wsdl. As per the book the Metro, bundled with glassfish, will automatically generate all the dependent class files, which we generate using wsgen, and also webservice.xml & sun-jaxws.xml which doesn't seems to be happening. Do I need to do some customization to make it happen automatically with providing my own custom web.xml & sun-jaxws.xml?
Thanks Himai. I didn't check this since quite long.
I have fixed the problem. The issue was with the client.xml. The code given in the book had:


but when i downloaded the book code i found that it was "UsernameToken" instead of "RequiredUsernameToken".

After correcting this it prompted me the username/password and then everything worked fine. Thank you so much for your time & help.

Hi Shailesh,
Since you are already Sun Certified Programmer you can take up the web service exam. Please refer the below link for details :
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=458&get_params=p_track_id:JEE6WSD
Sure I will try the running the downloaded code as is.
I had compared server.xml and its same. Will give a try again.
Thanks Himai for your input. I had tried the same as given in the book and also compared from the downloaded code from given link. However when I run my program it doesn't asks for username/password and that' what I believe is causing the issue. I am listing my client side source code (note: I had used existing TimeServer service instead of creating new Echo service):

Client code:




Handler code:




Prompter



When I run the client program after publishing the service I get following error from service, indicating that security header is missing:


C:\pbx_u01\apps\JavaWrkspcs\WebService\target\classes>java -cp .;..\WebService-1.0-SNAPSHOT\WEB-INF\lib\log4j-1.2.14.jar;..\WebService-1.0-SNAPSHOT\WEB-INF\lib\xws-security-3.0.jar;..\WebService-1.0-SNAPSHOT\WEB-INF\lib\jaxws-tools-2.2.8.jar com.java.jaxws.security.wss.SecureTimeServerClient
09:55:58,572 DEBUG main wss.SecureTimeServerClient:32 - adding ClientHandler
09:55:58,606 DEBUG main wss.ClientHandler:34 - costructor
09:55:58,632 DEBUG main wss.ClientHandler:43 - reading the config file
09:55:59,204 DEBUG main wss.ClientHandler:68 - handleMessage
09:55:59,205 DEBUG main wss.ClientHandler:71 - outbound: true
Sep 5, 2013 9:55:59 AM com.sun.xml.wss.impl.filter.DumpFilter process
INFO: ==== Sending Message Start ====
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getTimeAsString xmlns:ns2="http://ts.ch02/"/>
</S:Body>
</S:Envelope>
==== Sending Message End ====

09:55:59,994 DEBUG main wss.ClientHandler:102 - Outgoing message:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getTimeAsString xmlns:ns2="http://ts.ch02/"/></S:Body></S:Envelope>Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: com.sun.xml.wss.XWSSecurityException: com.sun.xml.wss.XWSSecurityException: Message does not conform to configured policy [ AuthenticationTokenPolicy(S) ]: No Security Header found
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at $Proxy28.getTimeAsString(Unknown Source)
at com.java.jaxws.security.wss.SecureTimeServerClient.main(SecureTimeServerClient.java:36)
Caused by: java.lang.RuntimeException: com.sun.xml.wss.XWSSecurityException: com.sun.xml.wss.XWSSecurityException: Message does not conform to configured policy [ AuthenticationTokenPolicy(S) ]: No Security Header found
at com.java.jaxws.security.wss.EchoSecurityHandler.handleMessage(EchoSecurityHandler.java:100)
at com.java.jaxws.security.wss.EchoSecurityHandler.handleMessage(EchoSecurityHandler.java:1)
at com.sun.xml.ws.handler.HandlerProcessor.callHandleMessage(HandlerProcessor.java:292)


Note: I have removed the logger statement from the code to reduce the no of lines and also not given the server code as I believe it has no issue.
Hi All,
I am trying to test the WS-Security example (Echo example on page 229) from webservices Up and running book. However the Prompter (CallbankHandler) is not being invoked so I am not able to pass the username/password so I get No Security Header found in message" error in EchoSecurityHandler.handleMessage(). Also I don't see Verifier (CallbankHandler) being invoked when msg is received at EchoSecurityHandler. I have followed the steps given in the book.
If someone was able to run and test example then please guide me.

Thanks in advance.
Well learning Webservices are not straightforward as SCJP & SCWCD. The best way to read java webservices up and running is by writing program and testing it. Just reading won't create any interest.
If you are familiar with maven then create a maven project and start testing the sample example in the book. Its very easy using Maven project.
I am also preparing for the Web service certification and I am about to finish this book. Yes, sometime there might be instances where some material has been missed or wrong for given sample example but you can correct it by doing your own research.
Happy learning..
Hi Ranchers,
Today I cleared the OCEWCD6 exam with 92%.
The feeling after clearing the exam is worth the effort.
Thanks to all rancher here. It is the good place to get the info about Books, exam simulator and getting your question answered. Also reading other's questions and their answers helps a lot.
I would like to share my experience for the preparation:
  • I spent almost 3 months for studying, practicing and attempting a lot of exam simulators. On working days 1-2 hours a day and on weekend 4-5 hours a day. This includes complete break for almost 15 days due to vacation travel.
  • I started with Head First Servlet, 2nd edition book. Practiced for most of the topics and attempted the question at the end of each chapters with on an average of 70-80%. This book covers most of the exam objectives, though not enough for EE6.
  • Read the Servlet/JSP/EL/JSTL specs to cover the new topics, specially Annotation & Pluggability, Asynchronous, Security ect. I read these new topics 2-3 times to get comfortable.
  • Examulator: Lot of questions from SCWCD.
  • Niko's Free SCWCD Mock Exam was very useful to test on basic concepts.
  • Piotr free exam simulator for Java EE6 new topics is must have. Don't forget to attempt these question before appearing for exam. Thank Piotr for making such a good collection of questions. They are just awesome.
  • Bipin's free mock exam for SCWCD. Missed the URL for his page.
  • Enthuware mock exams helps a lot to make me ready for the exam. This is worth every penny you pay. Their support team is very prompt to answer your any question. My all questions had been answered just in a day and till now I didn’t find any single question which I can say is given wrong. I suggest to buy this, if you plan, at least before 15 days (sooner the better) of your exam so that you get enough time to attempt all test sets. It has 10 sets. One set is good for a day, assuming working day, as it takes more time to go through the questions after than attempting it.


  • Enthuware mock exam results:
    Test 1- 63%
    Test 2- 77%
    Test 3- 88%
    Test 4- 79%
    Test 5- 88%
    Test 6- 82%
    Test 7- 79%
    Test 8- 72%
    Test 9- 75%
    Final Test -78%
    -------------------
    Average: 78%

    Head first servlet final exam score: 58%. This scared me first but then somehow I consoled my mind that everything will be okay in final exam.
    Note: There are couple of questions having error. So please refer the errata to avoid any frustration, if you get low score.

    Read the new topics (Annotation, Asynchronous, Security) carefully from specs. Do review the questions once finished before submitting, as I found few questions which I had selected initially wrong.
    Next OCEWSD6.

    Thanks & Best Regards,
    Sanjay Singh
    5 years ago

    My second question is if I declare a listener in DD which should not be, do I get an Exception ?



    you will not get any error, that's what I can see in tomcat 7.
    The Transfer Object is the copy of remote entity so during the time we data is send to view layer over the network it might be altered by some other program. So Transfer Object might have the stale state. E.g. the view requests for Employee details. The employee data is sent to view in a Transfer Object EmployeeDTO object. While the view gets it and process it some other program can update the Employee data and hence stale state of EmployeeDTO. I hope this helps.
    Hi Frits,

    I don't find any details if java doc that PrintWriter buffers the output. The java doc for PrintWriter obtained from ServletResponse is as following, which clearly says that we need to call the flush() method explicitly to commit the response::


    So I am also confused with above behavior.
    The following should be correct implementation:


    and