From: James A. <ja...@ja...> - 2014-07-22 20:04:09
|
Hi Sara, To send XML encoded messages, you need to pass an instance of DefaultXMLParser into the constructor of HohClientSimple. The client internally uses whatever parser it is passed (the sample you linked to uses a pipe parser) to encode the message object. Cheers, James On Tue, Jul 22, 2014 at 3:33 PM, Sara Fatima <sar...@gm...> wrote: > Hi all, > > I am using this example > <http://hl7api.sourceforge.net/hapi-hl7overhttp/doc_hapi.html> to send > hl7 message over http. My aim is to send a PIX message to an OpenHIE end > point. The message is being send to the below host: > > - Host: iol.sandbox.ohie.org > - Port: 5001 > - Basic auth details: > - username: admin > - password: admin > - HTTP method: POST > - HTTP Path: /ws/rest/v1/patients/ > > However at the below line IReceivable<Message> receivable = > client.sendAndReceiveMessage(sendable); I am facing an exception. > This is the exception which I am facing: > > > ca.uhn.hl7v2.hoh.api.NonHl7ResponseException: Invalid Content-Type: > text/plain > at > ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.doReadContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:233) > at > ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readHeadersAndContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:541) > at > ca.uhn.hl7v2.hoh.raw.client.AbstractRawClient.doSendAndReceiveInternal(AbstractRawClient.java:159) > at > ca.uhn.hl7v2.hoh.raw.client.AbstractRawClient.sendAndReceive(AbstractRawClient.java:279) > at > ca.uhn.hl7v2.hoh.raw.client.HohRawClientSimple.sendAndReceive(HohRawClientSimple.java:55) > at > ca.uhn.hl7v2.hoh.hapi.client.AbstractClient.sendAndReceiveMessage(AbstractClient.java:161) > at > org.openmrs.module.IHEInteroperability.SendMessageUtility.hl7OverHttp(SendMessageUtility.java:164) > at > org.openmrs.module.IHEInteroperability.api.impl.IHEInteroperabilityServiceImpl.afterReturning(IHEInteroperabilityServiceImpl.java:79) > at > org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:51) > at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) > at org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:122) > > I understand that OpenHIE is expecting the message to be in XML format, so > I did the below, > > //Converting the hl7 message into xml > Parser pipeParser = new PipeParser(); > String encodedMessage = pipeParser.encode(adt); > System.out.println(encodedMessage); > pipeParser = new DefaultXMLParser(); > String xmlMessage = pipeParser.encode(adt); > ISendable sendable = new MessageSendable(xmlMessage); // However here it > is expecting a Message object, hence I cannot provide xmlMessage. > Could someone guide me how I could resolve this issue? > Thanks & Regards > Sara Fatima > > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Hl7api-devel mailing list > Hl7...@li... > https://lists.sourceforge.net/lists/listinfo/hl7api-devel > > |