web services - JAXWS / JAXB doesn't bind attributes of references Object from seperate jar -
problem:
when jaxb unmarshalls xml object tree, attributes of objects seperate jar (and schema) not set , remain null.
see code below. on unmarshalling, attributes of meldingtype class remain null, though soap message has filled 'code' , 'melding' child-elemens in 'meldingen' elements.
if create 'local' version of meldingtype in .war , place .xsd definition of meldingtype in out.xsd, works perfectly. :(
how can work seperate jar, can share common jaxb objects common .xsd's?
situation
i have war , jar file.
- the .war contains class 'requesttype', package-info, out.xsd , out.wsdl.
- the .jar contains class 'meldingtype', package-info, , schema.xsd
war file
package info:
@javax.xml.bind.annotation.xmlschema(namespace = "http://schemas.xxx.nl/schema/out/v0010", elementformdefault = javax.xml.bind.annotation.xmlnsform.qualified) package nl.xxx.out.web.model;
requesttype
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "xboutrequesttype", proporder = { "kenmerk", "meldingen" }) public class xboutrequesttype { @xmlelement(required = true) protected string kenmerk; @xmlelement(required = true) protected list<meldingtype> meldingen = new arraylist<meldingtype>(); public string getkenmerk() { return this.kenmerk; } public list<meldingtype> getmeldingen() { return this.meldingen; } }
out.xsd
<?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:ref="http://schemas.xxx.nl/schema/v0010" targetnamespace="http://schemas.xxx.nl/out/v0010" xmlns="http://schemas.xxx.nl/out/v0010" elementformdefault="qualified"> <xsd:element name="request" type="requesttype"/> <xsd:element name="respomse" type="responsetype"/> <xsd:complextype name="requesttype"> <xsd:sequence> <xsd:element name="kenmerk" type="ref:kenmerktype" minoccurs="1"/> <xsd:element name="meldingen" type="ref:meldingtype" minoccurs="1" maxoccurs="unbounded"/> </xsd:sequence> </xsd:complextype> <xsd:complextype name="xboutresponsetype"/> </xsd:schema>
out.wsdl
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://schemas.xxx.nl/wsdl/out/v0010" xmlns:typ="http://schemas.xxx.nl/schema/out/v0010" xmlns:xsd="http://www.w3.org/2001/xmlschema" name="xbrender" targetnamespace="http://schemas.xxx.nl/wsdl/out/v0010"> <wsdl:types> <xsd:schema targetnamespace="http://schemas.xxx.nl/wsdl/out/v0010" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:import namespace="http://schemas.xxx.nl/schema/out/v0010" schemalocation="out.xsd" /> </xsd:schema> </wsdl:types> <wsdl:message name="request"> <wsdl:part name="body" element="typ:request" /> </wsdl:message> <wsdl:message name="response"> <wsdl:part name="body" element="typ:response" /> </wsdl:message> <wsdl:porttype name="porttype"> <wsdl:operation name="execute"> <wsdl:input message="tns:request" /> <wsdl:output message="tns:response" /> </wsdl:operation> </wsdl:porttype> <wsdl:binding name="soapbinding" type="tns:porttype"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="execute"> <soap:operation soapaction="execute"/> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="service"> <wsdl:port binding="tns:soapbinding" name="soapbinding"> <soap:address location="http://localhost:9080/dummy" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
jar
package info:
@javax.xml.bind.annotation.xmlschema(namespace = "http://schemas.xxx.nl/schema/v0010") package nl.xxx.schema.jaxb.model;
meldingtype
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "meldingtype", proporder = { "code", "melding" }) public class meldingtype { @xmlelement(required = true) private string code; @xmlelement(required = true) private string melding; public meldingtype() { } public meldingtype(final string code, final string melding) { this.code = code; this.melding = melding; } public string getcode() { return this.code; } public string getmelding() { return this.melding; } public void setcode(final string code) { this.code = code; } public void setmelding(final string melding) { this.melding = melding; } }
schema.xsd
<?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema" targetnamespace="http://schemas.xxx.nl/schema/v0010" xmlns="http://schemas.xxx.nl/schema/v0010" elementformdefault="qualified"> <xsd:simpletype name="kenmerktype"> <xsd:restriction base="xsd:string"> <xsd:minlength value="12" /> <xsd:maxlength value="32" /> </xsd:restriction> </xsd:simpletype> <xsd:complextype name="meldingtype"> <xsd:sequence> <xsd:element name="code" type="xsd:string" minoccurs="1" /> <xsd:element name="melding" type="xsd:string" minoccurs="1" /> </xsd:sequence> </xsd:complextype> </xsd:schema>
Comments
Post a Comment