Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Web Services and the fly likes Requesting the method in the WS hangs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Requesting the method in the WS hangs" Watch "Requesting the method in the WS hangs" New topic
Author

Requesting the method in the WS hangs

feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
I am trying to get a image from the server directory which is tomcat under webapps to the client but no result it just keeps hanged
the code is:
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
Toolkit.createImage is not a good way to load an image on the server; use javax.imageio.ImageIO.read instead.


Ping & DNS - my free Android networking tools app
feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
Where to store image1.jpg file
feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
When I compiled the code I got the following error



C:\Documents and Settings\fa00064\My Documents\NetBeansProjects\WebApplication1>
javac -d . src\java\services\ImageService.java
src\java\services\ImageService.java:21: package com.sun.xml.ws.developer does no
t exist
wsContext.getMessageContext().put(com.sun.xml.ws.developer.JAXWSPropertie
s.MTOM_THRESHOLOD_VALUE, 0);
^
1 error

Can You tell me how to solve it?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
Where to store image1.jpg file

Wherever you want to. Just give ImageIO.read an absolute path to it.

package com.sun.xml.ws.developer does not exist

You'll need to add whatever jar file contains this package to the classpath during compilation, and also when running the code.
feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
Execuseme from where I got the jar files and how?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
Since you're using classes that are part of the JAX-WS API, that's where I would start investigating. Maybe one of its jar files contains them.
Junior Zhang
Greenhorn

Joined: Feb 01, 2008
Posts: 6
feda alshahwan wrote:Execuseme from where I got the jar files and how?

You can try this site to find the jar: http://javacio.us/
And this is the search result:
http://javacio.us/subscribers/classes/com.sun.xml.ws.developer.JAXWSProperties
feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
Than you for the useful link but when I saved it where it should be and how to include it in the compilation classpath?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
Are you familiar with the "-classpath" switch, which is used both for compiling and for running Java code? It can be used to point to all the jar files required for code to execute.

On the server, put the jar file in the WEB-INF/lib directory.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
feda alshahwan wrote:I think that using REST for consuming and producing web services by mobiles is better. But since I know nothing about mobile applications and REST. So How can I start doing it please?


I would like to create a web service that takes numbers from client that corresponds to jpg files and returns html page that contains the chosen jpg's . What is the best way to depelop it ?thankyou


The scenario is changed as follows: client send numbers from 1-5 it can be one number or 2 or three choices server send the pictures corresponding to the chosen numbers


Ulf had pointed out in the other topic that an HTML page doesn't contain the images but only links to it. A web browser will open a separate connection for each image and download it separately - nice and simple.

So you have to ask yourself - is the benefit of downloading multiple images with a single request worth the overhead and complexity of dealing with SOAP and MTOM on the mobile consumer end? Wouldn't it make sense to give each image its own URL and simply download them separately - as images? Those requirements can be filled with a simple servlet implementation. You could even use Jersey if you really wanted to. Here is a quick and dirty proof of concept that I slapped together two months ago.

Tomcat 6.0.18 at C:\opt\tomcat
Jersey at C:\opt\tomcat\jersey\lib (asm-3.1.jar, jersey-core-1.0.1.jar, jersey-server-1.0.1.jar, jsr311-api-1.0.jar).
Modified C:\opt\tomcat\conf\catalina.properties line to shared.loader=C:/opt/tomcat/jersey/lib/*.jar

C:\opt\tomcat\webapps\helloimages\WEB-INF\ImageStore.java


You'll have to supply your own dontcare.png, happy.png, grumpy.png, thrilled.png images.

C:\opt\tomcat\webapps\helloimages\WEB-INF\ImageOutStreamer.java


C:\opt\tomcat\webapps\helloimages\WEB-INF\web.xml


C:\opt\tomcat\webapps\helloimages\WEB-INF\c.bat


Open a console window and change directory to C:\opt\tomcat\webapps\helloimages\WEB-INF and compile by running c.bat. Start up Tomcat and point your browser to
http://localhost:8080/helloimages/12345678/image
http://localhost:8080/helloimages/87654321/image
http://localhost:8080/helloimages/12348765/image
http://localhost:8080/helloimages/87651234/image
to see the different images.

The next step would be to support the HTTP PUT method to overwrite the existing images with new ones ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Requesting the method in the WS hangs