IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Java Discussion :

envoie de fichier


Sujet :

Services Web Java

  1. #1
    Membre très actif
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    549
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 549
    Par défaut envoie de fichier
    salut

    j'ai fait un web service ainsi qu'une application client pour l'utiliser

    le web service réceptionne un un fichier
    le paramètre de la méthode u web service est un objet qui contient quelques attribut string ainsi qu'un fichier (DataHandler)

    lorsque le fichier à envoyer est de 3, 4 meg...... tomcat retourne

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    com.sun.xml.ws.transport.http.servlet.WSServletDelegate doGet 
    GRAVE: caught throwable 
    java.lang.OutOfMemoryError: Java heap space 
            at java.util.Arrays.copyOfRange(Arrays.java:3209) 
            at java.lang.String.<init>(String.java:216) 
            at java.lang.StringBuffer.toString(StringBuffer.java:585) 
            at com.ctc.wstx.util.TextBuffer.contentsAsString(TextBuffer.java:403) 
            at com.ctc.wstx.sr.BasicStreamReader.getText(BasicStreamReader.java:821) 
            at com.sun.xml.ws.encoding.MtomCodec$MtomXMLStreamReaderEx.getPCDATA(MtomCodec.java:427) 
            at com.sun.xml.bind.v2.runtime.unmarshaller.StAXExConnector.handleCharacters(StAXExConnector.java:66) 
            at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:187) 
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360) 
            at com.sun.xml.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:120) 
            at com.sun.xml.bind.api.Bridge.unmarshal(Bridge.java:233) 
            at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$DocLit.readRequest(EndpointArgumentsBuilder.java:543) 
            at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:243) 
            at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:95) 
            at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:629) 
            at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:588) 
            at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:573) 
            at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:470) 
            at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:295) 
            at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:515) 
            at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:285) 
            at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:143) 
            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:155) 
            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:189) 
            at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:76) 
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306) 
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
            at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) 
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244) 
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    et du côté de l'application client j'ai

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    Exception in thread "main" com.sun.xml.internal.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html;charset=utf-8 Supported ones are: [text/xml] 
            at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:116) 
            at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:280) 
            at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:158) 
            at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:74) 
            at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:581) 
            at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:540) 
            at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:525) 
            at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:422) 
            at com.sun.xml.internal.ws.client.Stub.process(Stub.java:235) 
            at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:120) 
            at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:230) 
            at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210) 
            at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103) 
            at $Proxy32.depot(Unknown Source) 
            at webclient.WebClient.main(WebClient.java:48)
    pourtant dans le fichier conf de tomcat j'ai tenté:
    set CATALINA_OPTS="-Xms1024m -Xmx1024m"

    le web service recoit un objet: XmlDepot

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = { "nomFichier", "fichierZip" })
    @XmlRootElement(name = "xmlDepot")
    public class XmlDepot {
        @XmlElement(required = true)
        private String nomFichier;
        @XmlElement(required = true)
        @XmlMimeType("application/octet-stream")
        private DataHandler fichierZip;
        ...
    pour la classe Deposer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    @MTOM
    @WebService(serviceName = "Deposer")
    public class Deposer {
     
        /** This is a sample web service operation */
        @WebMethod(operationName = "hello")
        public String hello(@WebParam(name = "name") String txt) {
            return "Hello " + txt + " !";
        }
     
        /**
         * Web service operation
         */
        @WebMethod(operationName = "depot")
        public XmlRetour depot(@WebParam(name = "xmlDepot") XmlDepot xmlDepot) {
     
            System.out.println("fichier sauvegarde" + xmlDepot.getNomFichier());
            String path = "c:\\temp\\depot\\";
            String nomZip =  xmlDepot.getNomFichier();
     
            File f = new File(path + nomZip);
            DataHandler dh = xmlDepot.getFichierZip();
            FileOutputStream fsave;
            try {
     
                f.createNewFile();
                fsave = new FileOutputStream(f);
                dh.writeTo(fsave);
                fsave.flush();
                fsave.close();
            } catch (IOException ex) {
                Logger.getLogger(Deposer.class.getName()).log(Level.SEVERE, null, ex);
            }
    au niveau client

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
            Deposer_Service service = new Deposer_Service();
            Deposer port = service.getDeposerPort(new MTOMFeature());
     
            XmlDepot xmlDepot = new XmlDepot();
     
     
            String filename = "c:\\testFile.zip";
            File repositoryItemFile = new File(filename);
            DataHandler zipFile =
                    new DataHandler(new FileDataSource(repositoryItemFile));
            xmlDepot.setFichierZip(zipFile);
            xmlDepot.setNomFichier(fileName);
             port.depot(xmlDepot);
    j'utilise metro 2.0 et tomcat 7 (même résultat avec tomcat 6)

    pourquoi ça fonctionne que sur de petit fichier?

    merci

  2. #2
    Invité
    Invité(e)
    Par défaut
    Bonsoir,

    Il faudrait savoir qu'est-ce qu'il y a en mémoire au moment de l'erreur.
    Pour ça on peut utiliser l'option suivante sur la JVM:
    -XX:+HeapDumpOnOutOfMemoryError
    Puis on peut analyser le dump avec Eclipse par exemple.

Discussions similaires

  1. [debutant] envoi de fichier
    Par djchow dans le forum MFC
    Réponses: 8
    Dernier message: 21/03/2005, 16h57
  2. [HTTP] Envoi de fichiers par http
    Par Delendial dans le forum Entrée/Sortie
    Réponses: 7
    Dernier message: 03/09/2004, 09h37
  3. [Débutant] Envoi de fichier par socket
    Par zapho dans le forum Entrée/Sortie
    Réponses: 13
    Dernier message: 26/05/2004, 18h58
  4. [C#] Envoi de fichier xml
    Par minnieBis dans le forum ASP.NET
    Réponses: 16
    Dernier message: 25/05/2004, 14h28
  5. [Socket]envoie de fichier!!!
    Par SamDaKap dans le forum C++Builder
    Réponses: 5
    Dernier message: 20/11/2002, 08h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo