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

Format d'échange (XML, JSON...) Java Discussion :

Extensions Fichier xml


Sujet :

Format d'échange (XML, JSON...) Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    25
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Turquie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2015
    Messages : 25
    Par défaut Extensions Fichier xml
    Salut,
    je suis entrain de parcourir un fichier wsdl ,écrite en xml, avec Jdom .
    mais le problème se pose lorsque j’exécute la classe Jdom j'aurais un erreur parce qu’il n'accepte pas l'extension .wsdl.
    Quelqu'un peut m'aider comment je peux parcourir le fichier wsdl avec Jdom sans modifier son extension.
    Merci beaucoup d'avance.

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Qu'est-ce que tu entends par "j'exécute la classe Jdom". Quelle erreur tu as?

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    25
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Turquie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2015
    Messages : 25
    Par défaut extension .wsdl
    Voila la classe java:
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
     
    import java.io.*;
    import org.jdom.*;
    import org.jdom.input.*;
    import org.jdom.filter.*;
    import java.util.List;
    import java.util.Iterator;
    //import org.eclipse.core.resources.IFile;
     
    public class JDOM2
    {
       static org.jdom.Document document;
       static Element racine;
     
       public static void main(String[] args)
       {
          //On crée une instance de SAXBuilder
          SAXBuilder sxb = new SAXBuilder();
          try
          {
             //On crée un nouveau document JDOM avec en argument le fichier XML
             //Le parsing est terminé ;)
             document = sxb.build(new File("Example.wsdl"));
          }
     
          catch(Exception e){}
     
          //On initialise un nouvel élément racine avec l'élément racine du document.
          racine = document.getRootElement();
     
     
          //Méthode définie dans la partie 3.2. de cet article
        afficheALL();
     
       }
     
    //Ajouter cette méthodes à la classe JDOM2
    static void afficheALL()
    {
       //On crée une List contenant tous les noeuds "etudiant" de l'Element racine
       List listEtudiants = racine.getChildren("message");
     
       //On crée un Iterator sur notre liste
       Iterator i = listEtudiants.iterator();
       while(i.hasNext())
       {
          //On recrée l'Element courant à chaque tour de boucle afin de
          //pouvoir utiliser les méthodes propres aux Element comme :
          //sélectionner un nœud fils, modifier du texte, etc...
          Element courant = (Element)i.next();
          //On affiche le nom de l’élément courant
          System.out.println(courant.getAttributeValue("name") );
       }
    }
    }
    et les erreurs apparus sont:
    Exception in thread "main" java.lang.NullPointerException at JDOM2.main(JDOM2.java:29)


    Quelqu'un peut m'aider.

  4. #4
    Modérateur
    Avatar de joel.drigo
    Homme Profil pro
    Ingénieur R&D - Développeur Java
    Inscrit en
    Septembre 2009
    Messages
    12 430
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur R&D - Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2009
    Messages : 12 430
    Billets dans le blog
    2
    Par défaut
    Salut,

    On ne fait jamaie :

    En cas d'exception, on ne le sait pas. Et il y a probablement une exception, qui fait que document est null .

    Au minimum :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    catch(Exception e){
       e.printStackTrace();
    }
    Ensuite, donne nous la trace affichée.
    L'expression "ça marche pas" ne veut rien dire. Indiquez l'erreur, et/ou les comportements attendus et obtenus, et donnez un Exemple Complet Minimal qui permet de reproduire le problème.
    La plupart des réponses à vos questions sont déjà dans les FAQs ou les Tutoriels, ou peut-être dans une autre discussion : utilisez la recherche interne.
    Des questions sur Java : consultez le Forum Java. Des questions sur l'EDI Eclipse ou la plateforme Eclipse RCP : consultez le Forum Eclipse.
    Une question correctement posée et rédigée et vous aurez plus de chances de réponses adaptées et rapides.
    N'oubliez pas de mettre vos extraits de code entre balises CODE (Voir Mode d'emploi de l'éditeur de messages).
    Nouveau sur le forum ? Consultez Les Règles du Club.

  5. #5
    Membre Expert Avatar de tsuji
    Inscrit en
    Octobre 2011
    Messages
    1 558
    Détails du profil
    Informations forums :
    Inscription : Octobre 2011
    Messages : 1 558
    Par défaut
    Exception in thread "main" java.lang.NullPointerException at JDOM2.main(JDOM2.java:29)
    Vis à vis jdom v1, jdom v2 ne se distingue pas que les noms des jars, evidemment, il n'y a pas de raison de guarder les mêmes noms, il se distingue aussi par les noms de "package" remplaçant partout jdom par jdom2. Donc, si vos classpaths pointaient aux jars de jdom v2, il faut changer les imports et les références de jdom à jdom2, comme par exemples :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    //...
    import org.jdom2.*;
    import org.jdom2.input.*;
    //etc etc...
    static org.jdom2.Document document;
    //etc etc...

  6. #6
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2015
    Messages
    25
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Turquie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2015
    Messages : 25
    Par défaut erreur apparus
    Voila les erreurs apparus:

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    org.jdom.input.JDOMParseException: Error on line 14 of document file:/C:/Users/samsung/Desktop/copie%20de%20workspace/ATLplugin/eclipsehelio%20avec%20atl%20-%20Copie/workspace/Jdom2/Example.wsdl: The content of elements must consist of well-formed character data or markup.
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:465)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:810)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:789)
    	at JDOM.main(JDOM.java:23)
    Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.startOfMarkup(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
    	... 3 more
    Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.startOfMarkup(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:810)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:789)
    	at JDOM.main(JDOM.java:23)
    Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.startOfMarkup(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:810)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:789)
    	at JDOM.main(JDOM.java:23)
    Exception in thread "main" java.lang.NullPointerException
    	at JDOM.main(JDOM.java:31)
    et voila le fichier Example.wsdl
    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
    <?xml version="1.0" encoding="UTF-8" ?> 
    <definitions name="HelloService"   targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
       xmlns="http://schemas.xmlsoap.org/wsdl/"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <message name="SayHelloRequest">
          <part name="firstName"  type  ="xsd:string"/>
       </message>
       <message name="SayHelloResponse">
          <part name="greeting" type  ="xsd:string"/>
       </message>
       <portType name="Hello_PortType">
          <operation name="sayHello">
              < input  message="tns:SayHelloRequest"/>
               < output message="tns:SayHelloResponse"/>
          </operation>   </portType>
       <binding name="Hello_Binding" type="tns:Hello_PortType">
          <soap:binding style="rpc"
             transport="http://schemas.xmlsoap.org/soap/http"/>
          <operation name="sayHello">
             <soap:operation soapAction="sayHello"/>
             <input>  <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                   namespace="urn:examples:helloservice"
                   use="encoded"/>       </input>
    		         <output>
                <soap:body             encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                   namespace="urn:examples:helloservice"        use="encoded"/>   </output>     </operation>   </binding>
       <service name="Hello_Service">
          <documentation>WSDL File for HelloService</documentation>
          <port   binding="tns:Hello_Binding" name="Hello_Port">
             <soap:address location="http://www.examples.com/SayHello/" />
          </port>
       </service>
    </definitions>

Discussions similaires

  1. Recuperation du fichier xml
    Par Geulderack dans le forum XMLRAD
    Réponses: 10
    Dernier message: 28/02/2003, 11h06
  2. Lire un attribut dans un fichier XML en C++
    Par ti.k-nar dans le forum XML
    Réponses: 2
    Dernier message: 14/10/2002, 15h22
  3. [Kylix] Composant IBM pour fichiers XML
    Par Mister Nono dans le forum EDI
    Réponses: 1
    Dernier message: 29/09/2002, 20h28
  4. Balises HTML dans un fichier XML
    Par Bastet79 dans le forum XML/XSL et SOAP
    Réponses: 12
    Dernier message: 04/09/2002, 15h29

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