Web service who return an unvalid xml

Last post 07-06-2009 2:39 AM by oclone2300. 6 replies.

Sort Posts:

  • Web service who return an unvalid xml

    06-30-2009, 11:29 AM
    • Member
      1 point Member
    • oclone2300
    • Member since 05-11-2009, 10:14 AM
    • Posts 19

     Hello,

    I have developed an asmx webservice who return the results of a database request in two ways :

    1. I return a dataset

    2. I transform the dataSet into a specific table of object defined in my web service project and I return that.

    When I try this functions with internet explorer he return me a xml like that :

    <?xml version="1.0" encoding="utf-8" ?>

          - <ArrayOfCommande xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns="http://tempuri.org/">
          - <Commande>
           <Essence>ABIES</Essence>
           <Epaisseur>45</Epaisseur>
           <Largeur>145</Largeur>
          <Longueur>5.7</Longueur>
          <Quantite>84</Quantite>
          <Qualité>Déclassé</Qualité>
          <Traitement>NULL</Traitement>
          <Profil>4 chanfreins</Profil>
         <Qte_vente>478.8</Qte_vente>
         <Unité>ml</Unité>
       ...
     
      As you can see this xml is not valid because :
      - the character "-" is added at the beginning on some lines
      - the name of some of my elements have accents (for exemple Qualité) and the content of some éléments can also have some forbidden elements.
     
     So my questions are :
     - Must I rename my element's name by removing the accents , the same for the content and is there an easy way to do that for all the characters.
     - Must this xml be valid in order to be exploited by some others programs? If yes how to remove (or not generate) this "-"
     
     Thanks for your help!
     
     
     
     
  • Re: Web service who return an unvalid xml

    07-01-2009, 2:12 AM

    oclone2300:


    <?xml version="1.0" encoding="utf-8" ?>



    Instead of this...

    use this encoding..it will work

    <?xml version="1.0" encoding="ISO-8859-1" ?>


    as when i opened this xml in Browser it worked...

    myXml.xml:

    <?xml version="1.0" encoding="ISO-8859-1" ?>
     <ArrayOfCommande xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
     <Commande>
      <Essence>ABIES</Essence>
      <Epaisseur>45</Epaisseur>
      <Largeur>145</Largeur>
      <Longueur>5.7</Longueur>
      <Quantite>84</Quantite>
      <Qualité>Déclassé</Qualité>
      <Traitement>NULL</Traitement>
      <Profil>4 chanfreins</Profil>
      <Qte_vente>478.8</Qte_vente>
      <Unité>ml</Unité>
      </Commande>
      </ArrayOfCommande>


    Please mark this post as Answer if it is of help to you!

    " Every wall is a door..! "
  • Re: Web service who return an unvalid xml

    07-01-2009, 2:44 AM
    • Member
      1 point Member
    • oclone2300
    • Member since 05-11-2009, 10:14 AM
    • Posts 19

    Ok, thanks for your answer.

    I don't want just to succeed to open it. My customer who use this web service will call it from php or an other web language and so I want to be sure it will work.

    If I need to replace <?xml version="1.0" encoding="utf-8" ?> by <?xml version="1.0" encoding="ISO-8859-1" ?> how can I do that by programmation?

    You have also remove the dashes, but do you know where they come from?

    I realize that my XML doesn't appear very well on my first post so I edit it.

  • Re: Web service who return an unvalid xml

    07-01-2009, 3:03 AM
    Answer

    U simply have to append this line at the top of ur XML... and thoes dashes will come when u will see the xml in Browser.. if u open the same xml in note pad file ..it wont be there.. also if ur xml is under some url..then get the View Source of the page.. then copy the xml from there then open on note pad..also then u wont get any dashes.

    Please mark this post as Answer if it is of help to you!

    " Every wall is a door..! "
  • Re: Web service who return an unvalid xml

    07-01-2009, 3:36 AM
    • Member
      1 point Member
    • oclone2300
    • Member since 05-11-2009, 10:14 AM
    • Posts 19

    Ok ,thanks for your explanations.

  • Re: Web service who return an unvalid xml

    07-04-2009, 12:07 PM
    Answer

    There is nothing wrong with your XML! Internet Explorer is simply pretty-printing it for you. Click on one of the "-" and see what happens.

    John Saunders
  • Re: Web service who return an unvalid xml

    07-06-2009, 2:39 AM
    • Member
      1 point Member
    • oclone2300
    • Member since 05-11-2009, 10:14 AM
    • Posts 19

     Yes, sorry, thank you.

Page 1 of 1 (7 items)