Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] MOXy JSON unmarshall where JSON includes a namespace prefix where the XSD does not require a namespace prefix

Hi,

Its been a couple of weeks since I sent the email below.
Can anyone help, before I go to stackoverflow?
Thanks :-)


On 21 October 2014 16:40, Mark Himsley <mark.himsley@xxxxxxxxx> wrote:
> Hi,
>
> We've been using MOXy 2.5 for a few months. We're using it to pass JSON
> between our application and a 3rd party RESTful application.
>
> There are published schemas for the JSON.
>
> One of the published schemas includes elementFormDefault="qualified":
>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"; xmlns:bms="http://base.fims.tv";
>     xmlns:desc="http://description.fims.tv"; targetNamespace="http://base.fims.tv";
>     elementFormDefault="qualified">
> ...
> </schema>
>
> And one of them does not:
>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"; xmlns:bms="http://base.fims.tv";
>     xmlns:tms="http://transfermedia.fims.tv"; targetNamespace="http://transfermedia.fims.tv";>
> ...
> </schema>
>
> Our application is receiving JSON from the 3rd party. The problem is that
> the JSON from that 3rd party is including a namespace prefix for objects
> defined in the schema WITHOUT elementFormDefault="qualified":
>
> {
>   "tms.transferJob":
>   {
>     "bms.resourceID":"e1956e3c-b947-4d71-b939-97dd1a03dc01",
>     "bms.status":"running",
>     "bms.serviceProviderJobID":"JUPITER_JOB_e1956e3c_b947_4d71_b939_97dd1a03dc01"
>   }
> }
>
> That JSON is unmarshalled without an exception, but the 'transferJob' object
> is null.
>
> One way I can fix this is to make package-info include elementFormDefault =
> javax.xml.bind.annotation.XmlNsForm.QUALIFIED - by whatever means (adding to
> my jaxb:bindings file), but that means all the other objects from that
> schema which don't include a namespace prefix in the JSON (which is the
> majority of them) don't get unmarshalled.
>
> Alternatively I can alter the JSON to remove the namespace prefix - that's
> ugly!
>
>
> My understanding of NOT including elementFormDefault="qualified" meant that
> the namespace prefix is OPTIONAL. It appears that MOXy 2.5 does not agree
> with me, or I have missed a configuration.
>
> Is it possible for namespace prefixes in JSON with MOXy to be optional?
>
>
> Thanks in advance.


-- 
Mark Himsley


Back to the top