That is because you are missing a return acknowledgment in your
"RecieverApplication". What you probably should do is to call generateAck
and then return the outcome of that. It has nothing to do with the XML
parsing. Take a look at the example code:

*import java.io.IOException;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.app.Application;
import ca.uhn.hl7v2.app.ApplicationException;
import ca.uhn.hl7v2.app.Connection;
import ca.uhn.hl7v2.app.ConnectionHub;
import ca.uhn.hl7v2.app.Initiator;
import ca.uhn.hl7v2.app.SimpleServer;
import ca.uhn.hl7v2.llp.LLPException;
import ca.uhn.hl7v2.llp.LowerLayerProtocol;
import ca.uhn.hl7v2.llp.MinLowerLayerProtocol;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.model.v231.message.ORU_R01;
import ca.uhn.hl7v2.parser.DefaultXMLParser;
import ca.uhn.hl7v2.parser.Parser;
import ca.uhn.hl7v2.parser.PipeParser;

public class Mainer {

    private String host = "localhost";
    private int port = 999;

    public static void main(String[] args) {
        Mainer m = new Mainer();
        m.listen();
        try {
            String oruString =
"MSH|^~\\&|foo|foo||foo|200108151718||ORU^R01|12345|D|2.3.1|\rMSA|AA\r";
            Parser parser = new PipeParser();
            ORU_R01 message = (ORU_R01) parser.parse(oruString);
            m.send(message);
        } catch (HL7Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (LLPException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    private void send(Message oru) throws HL7Exception, LLPException,
            IOException {
        ConnectionHub connectionHub = ConnectionHub.getInstance();
        // Parser parser = new PipeParser();
        Parser parser = new DefaultXMLParser();
        Connection connection = connectionHub.attach(host, port, parser,
                MinLowerLayerProtocol.class);

        // The initiator is used to transmit unsolicited messages
        Initiator initiator = connection.getInitiator();
        Message response = initiator.sendAndReceive(oru);
        String responseString = (new DefaultXMLParser()).encode(response);
        System.out.println("Received response:\n" + responseString);
        connection.close();
    }

    public void listen() {
        LowerLayerProtocol llp = LowerLayerProtocol.makeLLP();
        // Parser parser = new PipeParser();
        Parser parser = new DefaultXMLParser();
        SimpleServer server = new SimpleServer(port, llp, parser);
        Application handler = new ReceiverApplication();
        server.registerApplication("*", "*", handler);
        server.start();
    }

    class ReceiverApplication implements Application {

        @Override
        public boolean canProcess(Message arg0) {
            return true;
        }

        @Override
        public Message processMessage(Message arg0)
                throws ApplicationException, HL7Exception {
            try {
                return arg0.generateACK();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

    }
}*



On 16 July 2010 12:16, YILDIRAY KABAK <[email protected]> wrote:

> Dear all,
>
> In my implementation, I have client and server, and the client send ORU R01
> (v2.5)
> messages to the server. The messages are exchanged successfully when using
> PipeParser.
> I suppose PipeParser send messages in "|" delimited format. However, in my
> implementation
> the client and server need to exchange XML messages and I have been unable
> to
> implement that. My codes are as follows:
>
> Client side:
> ---------------------------------------
>    private void send(Message oru) throws HL7Exception, LLPException,
> IOException {
>        ConnectionHub connectionHub = ConnectionHub.getInstance();
>        Connection connection = connectionHub.attach(host, port, new
> DefaultXMLParser(), MinLowerLayerProtocol.class);
>
>        // The initiator is used to transmit unsolicited messages
>        Initiator initiator = connection.getInitiator();
>        Message response = initiator.sendAndReceive(oru);
>        String responseString = (new DefaultXMLParser()).encode(response);
>        System.out.println("Received response:\n" + responseString);
>        connection.close();
>    }
> ---------------------------------------
> Server side:
> ---------------------------------------
>    public void listen() {
>        LowerLayerProtocol llp = LowerLayerProtocol.makeLLP(); // The
> transport protocol
>        DefaultXMLParser xmlParser = new DefaultXMLParser();
>        SimpleServer server = new SimpleServer(port, llp, xmlParser);
>        Application handler = new ReceiverApplication();
>        server.registerApplication("ORU", "R01", handler);
>        server.start();
>    }
> ---------------------------------------
>
> When executing the server and client I got the following timeout error:
>
>     [java] ca.uhn.hl7v2.HL7Exception: Timeout waiting for response to
> message with control ID '12345
>     [java]     at
> ca.uhn.hl7v2.app.Initiator.sendAndReceive(Initiator.java:154)
>     [java]     at
>
> tr.com.srdc.icardea.ihe.idco.observationCreator.ObservationCreator.send(Obse
> rvationCreator.java:309)
>     [java]     at
>
> tr.com.srdc.icardea.ihe.idco.observationCreator.ObservationCreator.run(Obser
> vationCreator.java:66)
>     [java]     at
>
> tr.com.srdc.icardea.ihe.idco.observationCreator.ObservationCreator.main(Obse
> rvationCreator.java:322)
>
> I will truly appreciate if you could kindly help me on this issue.
>
> Best regards,
>
> YILDIRAY KABAK, PhD.
>
> Software Research, Development and Consultation Ltd.
> ODTU Silikon Blok 1. Kat No:14
> Middle East Technical University Campus
> 06531 Ankara TURKEY
>
> Email: [email protected]
> Phone: +90 (312) 210 1763
> Fax: +90 (312) 210 1837
>
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Hl7api-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to