You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Robert Einsle <ro...@einsle.de> on 2009/12/17 17:37:20 UTC

XML-Parser Sensibility

Hi Mailinglist,

we are develope an WEB-Service with Apache CXF working with JXB 
Databinding. Wo work on Contract-First.

In our wsdl is an Object defined with Attributes like (striped):

--- cut ---
    <xsd:complexType name="Pruefanweisung">
        <xsd:sequence>
            <xsd:element name="pruefrhythmusPruefer" type="xsd:string"
                nillable="false" minOccurs="1" maxOccurs="1" />
[...]
        </xsd:sequence>
    </xsd:complexType>
--- cut ---

the generated Java-Class (striped):

--- cut ---
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Pruefanweisung", propOrder = {
    "pruefrhythmusPruefer",
[...]
})
public class Pruefanweisung {
    @XmlElement(required = true)
    protected String pruefrhythmusPruefer;
    /**
     * Gets the value of the pruefrhythmusPruefer property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *    
     */
    public String getPruefrhythmusPruefer() {
        return pruefrhythmusPruefer;
    }
    /**
     * Sets the value of the pruefrhythmusPruefer property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *    
     */
    public void setPruefrhythmusPruefer(String value) {
        this.pruefrhythmusPruefer = value;
    }
[...]
}
--- cut ---

The Attribute "pruefruethmusPruefer" is an Attribute of Pruefanweisung.
Now the Customer of the Service is sending something like:

--- cut ---
     <pruefrhythmusPruefer>XXXX Sport</pruefrhythmusPruefer>
     <pruefrhythmusPruefer>Hersteller</pruefrhythmusPruefer>
--- cut ---

Here the Attribute pruefrythmus comes more  than once. In my resulting 
Java-Class i can found the last occurance of the Attribute.

A second example of an Object:

--- cut ---
<projekte>
    <kennzeichen>X70</kennzeichen>
    <bezeichnung>
      <sprachkennzeichen>de_DE</sprachkennzeichen>
      <text>R10+(R10)</text>
    </bezeichnung>
    <kennzeichen>X99</kennzeichen>
    <bezeichnung>
      <sprachkennzeichen>de_DE</sprachkennzeichen>
      <text>R10 Bst. 2</text>
    </bezeichnung>
   </projekte>
--- cut ---

Here an colosing and starting "projekte"-Element is missing, but the 
Parser results my one Object of "projekte" containig the last Elements.

Is it Possible that the XML-Parser throws Exceptions if the sendt XML is 
bad?

Thanks a lot.

Robert



Re: XML-Parser Sensibility

Posted by Daniel Kulp <dk...@apache.org>.
You would need to turn on schema validation.

See:
http://cxf.apache.org/faq.html#FAQ-HowcanIturnonschemavalidationforjaxwsendpoint%253F

Dan


On Thu December 17 2009 11:37:20 am Robert Einsle wrote:
> Hi Mailinglist,
> 
> we are develope an WEB-Service with Apache CXF working with JXB
> Databinding. Wo work on Contract-First.
> 
> In our wsdl is an Object defined with Attributes like (striped):
> 
> --- cut ---
>     <xsd:complexType name="Pruefanweisung">
>         <xsd:sequence>
>             <xsd:element name="pruefrhythmusPruefer" type="xsd:string"
>                 nillable="false" minOccurs="1" maxOccurs="1" />
> [...]
>         </xsd:sequence>
>     </xsd:complexType>
> --- cut ---
> 
> the generated Java-Class (striped):
> 
> --- cut ---
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "Pruefanweisung", propOrder = {
>     "pruefrhythmusPruefer",
> [...]
> })
> public class Pruefanweisung {
>     @XmlElement(required = true)
>     protected String pruefrhythmusPruefer;
>     /**
>      * Gets the value of the pruefrhythmusPruefer property.
>      *
>      * @return
>      *     possible object is
>      *     {@link String }
>      *
>      */
>     public String getPruefrhythmusPruefer() {
>         return pruefrhythmusPruefer;
>     }
>     /**
>      * Sets the value of the pruefrhythmusPruefer property.
>      *
>      * @param value
>      *     allowed object is
>      *     {@link String }
>      *
>      */
>     public void setPruefrhythmusPruefer(String value) {
>         this.pruefrhythmusPruefer = value;
>     }
> [...]
> }
> --- cut ---
> 
> The Attribute "pruefruethmusPruefer" is an Attribute of Pruefanweisung.
> Now the Customer of the Service is sending something like:
> 
> --- cut ---
>      <pruefrhythmusPruefer>XXXX Sport</pruefrhythmusPruefer>
>      <pruefrhythmusPruefer>Hersteller</pruefrhythmusPruefer>
> --- cut ---
> 
> Here the Attribute pruefrythmus comes more  than once. In my resulting
> Java-Class i can found the last occurance of the Attribute.
> 
> A second example of an Object:
> 
> --- cut ---
> <projekte>
>     <kennzeichen>X70</kennzeichen>
>     <bezeichnung>
>       <sprachkennzeichen>de_DE</sprachkennzeichen>
>       <text>R10+(R10)</text>
>     </bezeichnung>
>     <kennzeichen>X99</kennzeichen>
>     <bezeichnung>
>       <sprachkennzeichen>de_DE</sprachkennzeichen>
>       <text>R10 Bst. 2</text>
>     </bezeichnung>
>    </projekte>
> --- cut ---
> 
> Here an colosing and starting "projekte"-Element is missing, but the
> Parser results my one Object of "projekte" containig the last Elements.
> 
> Is it Possible that the XML-Parser throws Exceptions if the sendt XML is
> bad?
> 
> Thanks a lot.
> 
> Robert
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog