It does resolve to 5050. It uses a properties file with 5050.

From: Mike Mills [mailto:m...@themills.id.au]
Sent: Friday, February 19, 2016 3:19 PM
To: hl7api-devel@lists.sourceforge.net
Subject: [HAPI-devel] Fwd: (no subject)

I forgot to CC the list in the response...

---------- Forwarded message ----------
From: Mike Mills <m...@themills.id.au<mailto:m...@themills.id.au>>
Date: Sat, Feb 20, 2016 at 7:18 AM
Subject: Re: [HAPI-devel] (no subject)
To: "Davies, Brian" 
<brian.dav...@mckesson.com<mailto:brian.dav...@mckesson.com>>

Your client is sending to "Integer.parseInt(env.getProperty("http.port"))", 
your server is listening on hard coded port 5050.

Does Integer.parseInt(env.getProperty("http.port")) resolve to port 5050? or as 
the property implies does it resolve to an http port?

Your error trace mentions "Invalid Content-Type: text/html", this implies your 
HL7 cient is talking to an http server and not an mllp server.


On Sat, Feb 20, 2016 at 6:29 AM, Davies, Brian 
<brian.dav...@mckesson.com<mailto:brian.dav...@mckesson.com>> wrote:
I am trying to test sending a message using a HAPI http client using the 
following configuration. The server starts and the message is sent but


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import ca.uhn.hl7v2.hoh.hapi.client.HohClientSimple;
import ca.uhn.hl7v2.hoh.sockets.TlsSocketFactory;
import ca.uhn.hl7v2.parser.PipeParser;

@Component
@PropertySource(value = {"classpath:connection.properties" })
public class HttpClientConfig {

               @Autowired
               private Environment env;

               @Bean
               public HohClientSimple httpClient() {
                              HohClientSimple client = new 
HohClientSimple(env.getProperty("http.host"), 
Integer.parseInt(env.getProperty("http.port")), 
env.getProperty("http.uri.path"),PipeParser.getInstanceWithNoValidation());
                              client.setSocketFactory(new TlsSocketFactory());
                              return client;
               }
}


import java.io.IOException;
import java.util.Map;

import ca.uhn.hl7v2.AcknowledgmentCode;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.protocol.ReceivingApplication;
import ca.uhn.hl7v2.protocol.ReceivingApplicationException;

public class MessageHandler implements ReceivingApplication {

       @Override
       public Message processMessage(Message theMessage, Map<String, Object> 
theMetadata)
                    throws ReceivingApplicationException, HL7Exception {

             Message response = null;
             try {
                    response = theMessage.generateACK();
             } catch (IOException e) {
                    e.printStackTrace();
             }
             return response;
       }

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

}



import java.io.IOException;

import javax.servlet.Servlet;

import org.eclipse.jetty.server.Server;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;



import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.app.Connection;
import ca.uhn.hl7v2.hoh.api.DecodeException;
import ca.uhn.hl7v2.hoh.api.EncodeException;
import ca.uhn.hl7v2.hoh.api.ISendable;
import ca.uhn.hl7v2.hoh.hapi.api.MessageSendable;
import ca.uhn.hl7v2.hoh.hapi.client.HohClientSimple;
import ca.uhn.hl7v2.hoh.llp.Hl7OverHttpLowerLayerProtocol;
import ca.uhn.hl7v2.hoh.util.ServerRoleEnum;
import ca.uhn.hl7v2.llp.LLPException;
import ca.uhn.hl7v2.llp.LowerLayerProtocol;
import ca.uhn.hl7v2.model.DataTypeException;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.model.v25.message.ADT_A01;
import ca.uhn.hl7v2.model.v25.message.ADT_A38;
import ca.uhn.hl7v2.model.v25.segment.DB1;
import ca.uhn.hl7v2.model.v25.segment.MSH;
import ca.uhn.hl7v2.model.v25.segment.SFT;
import ca.uhn.hl7v2.parser.EncodingNotSupportedException;

import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {HttpClientConfig.class},loader = 
AnnotationConfigContextLoader.class)
public class SendingRequestTest {

               @Autowired
               private HohClientSimple httpClient;
               @Before
    public void initServer() throws Exception{
               Server server = new Server(5050);
                              ServletContextHandler handler = new 
ServletContextHandler(server, "/testURL");
                              Servlet servlet=new HttpMessageReceiver();
                              handler.addServlet(new ServletHolder(servlet), 
"/appContext");
                              server.start();
                              System.out.println("Server started!!");
    }
    @Test
    public void testSendReceive(){

               try {
                              ADT_A38 adt=new ADT_A38();
               MSH msh1=adt.getMSH();
               msh1.getMsh1_FieldSeparator().setValue("|");
               msh1.getMsh2_EncodingCharacters().setValue("^~\\&");
               SFT sft=adt.getSFT();
               adt.insertSFT(sft, 0);
               DB1 db1=adt.getDB1();
               adt.insertDB1(db1, 0);
               ISendable sendable = new MessageSendable(adt);
                                             //Message 
message=createTestMessage();
                              httpClient.sendAndReceiveMessage(sendable);

                              } catch (DataTypeException e) {
                                             e.printStackTrace();
                                             System.out.println("datatype 
problem");
                              } catch (EncodingNotSupportedException e) {
                                             e.printStackTrace();
                                             System.out.println("encode not 
supported problem");
                                             System.exit(1);
                              } catch (HL7Exception e) {
                                                            e.printStackTrace();
                              } catch (DecodeException e) {
                                             e.printStackTrace();
                                             System.out.println("decode 
problem");
                                             System.exit(1);
                              } catch (IOException e) {
                                             e.printStackTrace();
                                             System.exit(1);
                              } catch (EncodeException e) {
                                             e.printStackTrace();
                                             System.out.println("encode 
problem, not that it's not supported");
                              }

    }

               }

I get the following error:

   Feb 19, 2016 1:14:25 PM org.springframework.context.support.GenericApplicati 
                                                                                
                                                 onContext prepareRefresh
    INFO: Refreshing 
org.springframework.context.support.GenericApplicationConte                     
                                                                                
                             xt@3b733273: startup date [Fri Feb 19 13:14:25 CST 
2016]; root of context hierar                                                   
                                                                               
chy
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See 
http://www.slf4j.org/codes.html#StaticLoggerBinder<http://cp.mcafee.com/d/k-Kr4x8qdEIfLCzB5VdxYSrhhjhupjvvhdEEFELcFKcECPpISHoHZalxOVJ_TkNlCTLyLSRWX3H0GVvnhlwwwWaAdSMGO_uMVVNZNfXCPpISr01kfto4u00VqG7QU70ocjSsH1mF4zYhCk4fyrdEIKndCXCQPrNKVJUSyrh>
 for further de                                                                 
                                                                 tails.
SendingRequestTest > testSendReceive STANDARD_OUT
    Server started!!

SendingRequestTest > testSendReceive STANDARD_ERR                               
                                                                                
                   OR
    ca.uhn.hl7v2.hoh.api.NonHl7ResponseException: Invalid Content-Type: 
text/html                                                                       
                                                           l
        at 
ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.doReadContentsFro           
                                                                                
                                       
mInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:233)
        at 
ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readHeadersAndCon           
                                                                                
                                       
tentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:541)
        at 
ca.uhn.hl7v2.hoh.raw.client.AbstractRawClient.doSendAndReceiveInterna           
                                                                                
                                       l(AbstractRawClient.java:159)
        ….


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140<http://cp.mcafee.com/d/1jWVIg6wUSyM--qeknAS7PpJ55d5VBdZZ4SyyCyYOCUOyrdCPqJyLQFm7bCT_tj5mru-a_rnHIeI2HBZt5m223EGgTr2HbZX3DD7T4_KrdCPpI06ISgR2D4ugGSgf-NYH5u1K4gxG6mfaAF879zAS7xObWbgg14CPIohoKrdEIKndCXCQPrNKVJUSyrh>
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net<mailto:Hl7api-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/hl7api-devel<http://cp.mcafee.com/d/5fHCNAp410idEIfLCzB5VdxYSrhhjhupjvvhdEEFELcFKcECPpISHoHZalxOVJ_TkNlCTLyLSRWX3H0GVvnhlwwwWaAdSMGO_uMVVNZNfXCPpISr9PCJhbcfBiteFlKdLt00_MdM-l9QM-l9OwXn2pUXlF5Qfc-urdEIKndCXCQPrNKVJUSyrh>


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to