1 package ca.uhn.hl7v2.examples.hoh;
2
3 import ca.uhn.hl7v2.hoh.api.IAuthorizationServerCallback;
4 import ca.uhn.hl7v2.hoh.api.IMessageHandler;
5 import ca.uhn.hl7v2.hoh.api.IReceivable;
6 import ca.uhn.hl7v2.hoh.api.IResponseSendable;
7 import ca.uhn.hl7v2.hoh.api.MessageProcessingException;
8 import ca.uhn.hl7v2.hoh.auth.SingleCredentialServerCallback;
9 import ca.uhn.hl7v2.hoh.raw.api.RawSendable;
10 import ca.uhn.hl7v2.hoh.raw.server.HohRawServlet;
11
12
13
14
15
16 public class ExampleRawHl7OverHttpServlet extends HohRawServlet {
17
18
19
20
21 public ExampleRawHl7OverHttpServlet() {
22
23
24
25
26
27
28 setMessageHandler(new ExampleMessageHandler());
29
30
31
32
33
34 IAuthorizationServerCallback callback =
35 new SingleCredentialServerCallback("someusername", "apassword");
36 setAuthorizationCallback(callback);
37
38 }
39
40
41
42
43
44 private static class ExampleMessageHandler implements IMessageHandler<String> {
45
46
47
48
49
50 public IResponseSendable<String> messageReceived(IReceivable<String> theReceived)
51 throws MessageProcessingException {
52
53 String incomingRawMsg = theReceived.getMessage();
54 System.out.println("Received message:\n" + incomingRawMsg);
55
56
57
58
59
60
61
62 String ack = "MSH|.....";
63
64
65
66
67
68
69
70 boolean somethingFailed = false;
71
72
73 return new RawSendable(ack);
74 }
75
76 }
77
78 }