Stream: hapi
Topic: hapi-fhir: issue 282: CXF Rest Webservice failing to mars...
Zulip HAPI Bot (Jan 13 2016 at 12:59):
gafoorsk opened issue 282
Hi ,
I am implementing CXF Rest service with FHIR Data Model(HAPI) and i am using "org.codehaus.jackson.jaxrs.JacksonJsonProvider" for Marshaling/unmarshalling .
when i try to give Patient input json, CXF is not able to unmarshall the patient FHIR Data model object.
do i need to specify any json provider in CXF Rest service configuration?
Zulip HAPI Bot (Jan 13 2016 at 14:37):
KevinMayfield commented on issue 282
If your just using HAPI as a data model you could switch to me.fhir. We use
it with our Apache Camel rest services, the code is virtually the same
(except for the (un)marshaling).
Believe HAPI also uses this package<dependency>
<groupId>me.fhir</groupId>
<artifactId>fhir-dstu2</artifactId>
<version>${hl7-fhir-me-version}</version>
</dependency>On 13 January 2016 at 12:59, gafoorsk <notifications@github.com> wrote:
Hi ,
I am implementing CXF Rest service with FHIR Data Model(HAPI) and i am
using "orgcodehausjacksonjaxrsJacksonJsonProvider" for
Marshaling/unmarshalling
when i try to give Patient input json, CXF is not able to unmarshall the
patient FHIR Data model object
do i need to specify any json provider in CXF Rest service configuration?—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282>.
Zulip HAPI Bot (Jan 13 2016 at 14:59):
jamesagnew commented on issue 282
Hi @gafoorsk , are you using CXF as a JAX-RS provider? If so, we have a JAX-RS Server module that was contributed by Agfa that will be included in the next release of HAPI (1.4, due very soon). You can find this here: https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jaxrsserver-base
If you're not doing JAX-RS, you probably need to implement a custom marshaller/unmarshaller for CXF. The FHIR model objects aren't designed to be natively marshalled by JAXB (you need to use HAPI's Parser) so that needs to be woven in.
The only other thing I'd mention is that it you have an existing stack using CXF it makes sense to try and build on it, but you might find it more pleasant to just use HAPI's server framework. It it much more tailored to the many specific rules in FHIR, so there will be a lot less boilerplate required than there would be trying to recreate the FHIR rules natively in CXF.
Zulip HAPI Bot (Jan 14 2016 at 16:21):
gafoorsk commented on issue 282
Hi ,
Thanks for reply.
I tried using me.FHIR jars, it's gives the following exception.
"Unrecognized field "resourceType" (Class
org.hl7.fhir.instance.model.Patient), not marked as ignorable"do you have any sample program available related to me FHIR on git hub?
Thanks,
GafoorOn Wed, Jan 13, 2016 at 8:07 PM, KevinMayfield <notifications@github.com>
wrote:If your just using HAPI as a data model you could switch to me.fhir. We use
it with our Apache Camel rest services, the code is virtually the same
(except for the (un)marshaling).
Believe HAPI also uses this package<dependency>
<groupId>me.fhir</groupId>
<artifactId>fhir-dstu2</artifactId>
<version>${hl7-fhir-me-version}</version>
</dependency>On 13 January 2016 at 12:59, gafoorsk <notifications@github.com> wrote:
Hi ,
I am implementing CXF Rest service with FHIR Data Model(HAPI) and i am
using "orgcodehausjacksonjaxrsJacksonJsonProvider" for
Marshaling/unmarshalling
when i try to give Patient input json, CXF is not able to unmarshall the
patient FHIR Data model object
do i need to specify any json provider in CXF Rest service configuration?—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282>.—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282#issuecomment-171310205>
.
Zulip HAPI Bot (Jan 14 2016 at 16:25):
gafoorsk commented on issue 282
Thanks James for replay,
As you suggested, i willtry with custom provider and use HAPI parser to
marshall/unmarshall.Thanks,
GafoorOn Wed, Jan 13, 2016 at 8:29 PM, James Agnew <notifications@github.com>
wrote:Hi @gafoorsk <https://github.com/gafoorsk> , are you using CXF as a
JAX-RS provider? If so, we have a JAX-RS Server module that was contributed
by Agfa that will be included in the next release of HAPI (1.4, due very
soon). You can find this here:
https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jaxrsserver-baseIf you're not doing JAX-RS, you probably need to implement a custom
marshaller/unmarshaller for CXF. The FHIR model objects aren't designed to
be natively marshalled by JAXB (you need to use HAPI's Parser) so that
needs to be woven in.The only other thing I'd mention is that it you have an existing stack
using CXF it makes sense to try and build on it, but you might find it more
pleasant to just use HAPI's server framework. It it much more tailored to
the many specific rules in FHIR, so there will be a lot less boilerplate
required than there would be trying to recreate the FHIR rules natively in
CXF.—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282#issuecomment-171321110>
.
Zulip HAPI Bot (Jan 14 2016 at 19:12):
jamesagnew commented on issue 282
Cool, best of luck!
Incidentally, if you do get a custom provider working for CXF and happen to want to contribute back any info on how to make this working, we're always happy to find a spot for it on our website. Others would undoubtedly find it useful. :)
Zulip HAPI Bot (Jan 14 2016 at 19:12):
jamesagnew closed issue 282
Zulip HAPI Bot (Jan 15 2016 at 08:28):
KevinMayfield commented on issue 282
Gafoor,
Have left out building the Patient resource:
*// Patient is import org.hl7.fhir.instance.model.Patient;*
*Patient patient = this.toFHIR(patientrs);**String Response = null; *
*if (!xmlformat)*
*{*
* Response = ResourceSerialiser.serialise(patient, ParserType.JSON);*
*}*
*else*
*{*
* Response = ResourceSerialiser.serialise(patient, ParserType.XML);*
*}*ResourceSerialiser class is below:
*import java.io.ByteArrayOutputStream;*
*import java.io.OutputStream;**import org.hl7.fhir.instance.formats.IParser.OutputStyle;*
*import org.hl7.fhir.instance.formats.JsonParser;*
*import org.hl7.fhir.instance.formats.ParserType;*
*import org.hl7.fhir.instance.formats.XmlParser;*
*import org.hl7.fhir.instance.model.Bundle;*
*import org.hl7.fhir.instance.model.Resource;*
*import org.slf4j.Logger;*
*import org.slf4j.LoggerFactory;**public class ResourceSerialiser {*
* private static Logger logger =
LoggerFactory.getLogger(ResourceSerialiser.class);*
* public static String serialise(Resource resource, ParserType type) {*
* try {*
* if (type == ParserType.XML) {*
* XmlParser composer = new XmlParser();*
* OutputStream out = new ByteArrayOutputStream();*
* composer.setOutputStyle(OutputStyle.PRETTY);*
* composer.compose(out, resource, true);*
* return out.toString();*
* } else {*
* JsonParser composer = new JsonParser();*
* OutputStream out = new ByteArrayOutputStream();*
* composer.setOutputStyle(OutputStyle.PRETTY);*
* composer.compose(out, resource);*
* return out.toString();*
* }*
* } catch (Exception e) {*
* logger.error("Unable to serialise FHIR resource", e);*
* }*
* return null;*
* }*
* public static String serialise(Bundle feed, ParserType type) {*
* try {*
* if (type == ParserType.XML) {*
* XmlParser composer = new XmlParser();*
* OutputStream out = new ByteArrayOutputStream();*
* composer.compose(out, feed, true);*
* return out.toString();*
* } else {*
* JsonParser composer = new JsonParser();*
* OutputStream out = new ByteArrayOutputStream();*
* composer.setOutputStyle(OutputStyle.PRETTY);*
* composer.compose(out, feed);*
* return out.toString();*
* }*
* } catch (Exception e) {*
* logger.error("Unable to serialise FHIR Bundle", e);*
* }*
* return null;*
* }*
*}*On 14 January 2016 at 16:21, gafoorsk <notifications@github.com> wrote:
Hi ,
Thanks for reply.
I tried using me.FHIR jars, it's gives the following exception.
"Unrecognized field "resourceType" (Class
org.hl7.fhir.instance.model.Patient), not marked as ignorable"do you have any sample program available related to me FHIR on git hub?
Thanks,
GafoorOn Wed, Jan 13, 2016 at 8:07 PM, KevinMayfield <notifications@github.com>
wrote:If your just using HAPI as a data model you could switch to me.fhir. We
use
it with our Apache Camel rest services, the code is virtually the same
(except for the (un)marshaling).
Believe HAPI also uses this package<dependency>
<groupId>me.fhir</groupId>
<artifactId>fhir-dstu2</artifactId>
<version>${hl7-fhir-me-version}</version>
</dependency>On 13 January 2016 at 12:59, gafoorsk <notifications@github.com> wrote:
Hi ,
I am implementing CXF Rest service with FHIR Data Model(HAPI) and i am
using "orgcodehausjacksonjaxrsJacksonJsonProvider" for
Marshaling/unmarshalling
when i try to give Patient input json, CXF is not able to unmarshall
the
patient FHIR Data model object
do i need to specify any json provider in CXF Rest service
configuration?—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282>.—
Reply to this email directly or view it on GitHub
<
https://github.com/jamesagnew/hapi-fhir/issues/282#issuecomment-171310205>
.—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282#issuecomment-171688753>
.
Zulip HAPI Bot (Jan 15 2016 at 15:16):
gafoorsk commented on issue 282
Thanks for the help .
On Wed, Jan 13, 2016 at 8:07 PM, KevinMayfield <notifications@github.com>
wrote:If your just using HAPI as a data model you could switch to me.fhir. We use
it with our Apache Camel rest services, the code is virtually the same
(except for the (un)marshaling).
Believe HAPI also uses this package<dependency>
<groupId>me.fhir</groupId>
<artifactId>fhir-dstu2</artifactId>
<version>${hl7-fhir-me-version}</version>
</dependency>On 13 January 2016 at 12:59, gafoorsk <notifications@github.com> wrote:
Hi ,
I am implementing CXF Rest service with FHIR Data Model(HAPI) and i am
using "orgcodehausjacksonjaxrsJacksonJsonProvider" for
Marshaling/unmarshalling
when i try to give Patient input json, CXF is not able to unmarshall the
patient FHIR Data model object
do i need to specify any json provider in CXF Rest service configuration?—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282>.—
Reply to this email directly or view it on GitHub
<https://github.com/jamesagnew/hapi-fhir/issues/282#issuecomment-171310205>
.
Last updated: Apr 12 2022 at 19:14 UTC