@SuppressWarnings("rawtypes")
	public WSMessagesIn checkFromAddress(MessageContext msgContext) throws Exception {
		WSMessagesIn wsMessage = new WSMessagesIn();
		wsMessage.setStatusId(3);
		try {
		
			//we write it to log for now
			DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:S");
            Date date = new Date();
            String batchName = dateFormat.format(date).toString();

			System.out.println("*********Start of soap message in - " + batchName + " at time " + date +"****************");
			//1. we get the header
			SOAPEnvelope sm = msgContext.getEnvelope();
			//print to log for now
			//System.out.println("ENVELOPE");		
			//System.out.println(sm.toString());
			wsMessage.setPayload(sm.toString());
			SOAPHeader header = sm.getHeader();
			
			ArrayList headerBlocks = new ArrayList();
			try {		
				headerBlocks = header.getHeaderBlocksWithNSURI("urn:direct:addressing");
			} catch (Exception ex) {
				ex.printStackTrace();
			}
			if (headerBlocks.size() == 0) {
				wsMessage.setOrgId(0); 
				wsMessage.setStatusId(3); //reject
				wsMessage.setErrorId(19); //invalid header
				return wsMessage;
			}
			//2. we grab from address
			SOAPHeaderBlock hb = (SOAPHeaderBlock) headerBlocks.get(0);
			Iterator it1 = hb.getChildrenWithLocalName("from");
			String fromAddress = "";
			while (it1.hasNext()) {
				OMElement he = (OMElement) it1.next();
				fromAddress = he.getText();
			}
			if (fromAddress.equalsIgnoreCase("")) {
				wsMessage.setOrgId(0); 
				wsMessage.setStatusId(3); //reject
				wsMessage.setErrorId(19); //invalid header
				return wsMessage;
			}
			
			//3. we check to see if it is in table
			String domain = getDomain(fromAddress);
			if (domain == null) {
				wsMessage.setOrgId(0); 
				wsMessage.setStatusId(3); //reject
				wsMessage.setErrorId(19); //invalid header, missing @
				wsMessage.setFromAddress(fromAddress);
				return wsMessage;
			}
			
			wsMessage.setDomain(domain);
			
			//4. we check domain to see if it in the table 
			
			List <Integer> orgList = getOrgIdForWSMessage(domain);

			if (orgList.size() == 0) {
				wsMessage.setOrgId(0); 
				wsMessage.setStatusId(3); //reject
				wsMessage.setErrorId(20); //invalid sender
				wsMessage.setFromAddress(fromAddress);

				return wsMessage;
			} else if ( orgList.size() > 1){
				wsMessage.setOrgId(0); 
				wsMessage.setStatusId(3); //reject
				wsMessage.setErrorId(26); //multiple orgs were found for domain
				wsMessage.setFromAddress(fromAddress);
				return wsMessage;
			}
			
			//5. we set our WSMessage
			wsMessage.setOrgId(orgList.get(0)); 
			wsMessage.setStatusId(1);
			wsMessage.setFromAddress(fromAddress);
			return wsMessage;
			
			} catch (Exception ex) {
				System.err.println("error - checkFromAddress");
				ex.printStackTrace();
				return wsMessage;
			}
			
	}