This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes MTOM example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "MTOM example" Watch "MTOM example" New topic
Author

MTOM example

nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
i am running Ivan's example which is in 10.3 section. below is my wsdl



When i run the example in SOAPUI i got back bytes in response but attachment tab hadnothing in it. Only header tab has 6 properties. Am i missing something? i see the poseted wsdl in chapter and i have difference in policy tag also. Why is it so?

Thanks in advance
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
The policy declaration you have do look fine. It is not exactly match that in my book, but I think it is equivalent.
Are you deploying the service to GlassFish and if so, which version?
There may be some differences between, say, GlassFish 2 (which I used when writing the book) and GlassFish v3.
If you let me know what version you are using, I can try the service here.
Also, have you tried to run the client? With what result?
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
I am using glassfishv3 version. I have not tried other client, i used on soapui. I will give it a try but how to verify if respnose contains attachment. should i use TCP/IP monitoring tool.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
It turns out that the way I used to read the picture files, which worked fine in GlassFish v2, do not work in GlassFish v3.
I have corrected the retrievePicture method and the new version looks like this:

Thanks for pointing this problem out to me.
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
still no luck for me, I still got response but not attchment with new example also.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
GlassFish v3 has apparently changed what is the result of enabling MTOM in a service.
As you correctly point out, the policy declaration is different and if you look even closer, you can see that MTOM is no longer mandatory, but optional:

This causes soapUI to choose not to use MTOM when interacting with the service and thus you see no attachments in soapUI.
When I just tried the client program, shown later in section 10.3, and used a packet sniffer to examine the communication with the web service, then I found that MTOM was indeed enabled.
I will make updates to my study guide when I have time and when I have thought a little about the best way to write about this to cover both GlassFish v2 and v3.
Best wishes!

P.S. The client program seems to have a problem displaying the fetched picture now and then, I will look into this as well (guess I need to brush up my old Swing knowledge. ).
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
This fixes the client program (exchange the method with the same name for the new version below):

Best wishes!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Ah, finally! :-)
I managed to change the settings of the request in soapUI so that MTOM is forced, see picture below.
This way, you will get to see the attachment, as described in the tutorial!
Best wishes!



[Thumbnail for soapUI-requestproperties.jpg]

nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Yes... that works by chaning properties in soapui. Thanks alot for your help.
 
Don't get me started about those stupid light bulbs.
 
subject: MTOM example