Announcement Announcement Module
Collapse
No announcement yet.
Jaxb marshalling Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jaxb marshalling

    Hi,

    I'm trying to get work my web service. I use generated jaxb classes via xjc from XSD scheme.

    Code:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://sample.namespace"
        xmlns:tns="http://sample.namespace
        elementFormDefault="qualified">
    
    <xsd:element name="getObjectRequest"> 
        <xsd:complexType>
            <xsd:attribute name="ID" type="xsd:integer" />
        </xsd:complexType>
    </xsd:element> 
    
    <xsd:element name="getObjectResponse"> 
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="result" type="tns:returnResult">
                <xsd:element name="object" type="tns:bussinessObject" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
        <xsd:complexType name="bussinessObject" >
            <xsd:attribute name="Id" type="xsd:integer"/>
            <xsd:attribute name="Name" type="xsd:string"/>
        </xsd:complexType>
        <xsd:simpleType name="returnResult">
            <xsd:restriction base="xsd:token">
                <xsd:enumeration value="OK" />
                <xsd:enumeration value="Error" />
            </xsd:restriction>
        </xsd:simpleType>
    </xsd:schema>
    My endpoint method is bound to getObjectRequest and returns getObjectResponse. Everything goes fine. I can call endpont operation and I've got response. But bussinessObject is always null in response. Even if my endpoint method returns not null value.

    Problem seems to be in jaxb generated classes.

    Code:
    public class getObjectResponse {
    
        @XmlElement(required = true)
        protected ReturnResult result;
        @XmlElement(required = true)
        protected BussinessObject bussinessObject;
    When I put right namespace into @XmlElement annotation of bussinessObject, returned value is no longer null and contains expected value.

    Although, it is unacceptable to edit generated classes.

    Can you please help me, how to generate java files with namespaces declared in @XmlElement annotations, or how to tell jaxb marshaller to know the right namespace by default?
Working...
X