Adds attachments if present in soap web service message.

@param soapMessage the web service message.
@param message the response message builder.
508946
protected void handleInboundAttachments(final org.springframework.ws.soap.SoapMessage soapMessage,
                                            final SoapMessage message) {
        final Iterator<Attachment> attachments = soapMessage.getAttachments();

        while (attachments.hasNext()) {
            final Attachment attachment = attachments.next();
            final SoapAttachment soapAttachment = SoapAttachment.from(attachment);

            if (log.isDebugEnabled()) {
                log.debug(String.format("SOAP message contains attachment with contentId '%s'", soapAttachment.getContentId()));
            }

            message.addAttachment(soapAttachment);
        }
    }
687871
public void sendMessage(Message message)
    {
        ((DualMessageQueue)this.getMessageQueue()).getMessageStack().sendMessage(message);
        
        ((BaseMessage)message).setProcessedByClient(true);     // Make sure any server doesn't send this back up.

        super.sendMessage(message);
    }
623654
public void setPayloadProperty(BaseMessage message, Object msg, String strKey, Class<?> classKey)
   {
       Object data = message.get(strKey);
       if (data == null)
           return;
       this.setPayloadProperty(data, msg, strKey, classKey);
   }
124190
public SOAPMessage sendForMessage() {
		final HttpResponse res = sendForResponse();
		final MimeHeaders headers = new MimeHeaders();
		for (Entry<String, List<String>> entry : res.headers().entrySet()) {
			if(StrUtil.isNotEmpty(entry.getKey())) {
				headers.setHeader(entry.getKey(), CollUtil.get(entry.getValue(), 0));
			}
		}
		try {
			return this.factory.createMessage(headers, res.bodyStream());
		} catch (IOException | SOAPException e) {
			throw new SoapRuntimeException(e);
		}
	}
723465
public static byte [] readFile(SOAPMessage msg, Element el){
        Element include = XMLFormat.getFirstChildElement(el,"Include","http://www.w3.org/2004/08/xop/include");
        byte [] data  = null;
        if(include!=null){
            //LOG.debug("Reading XOP file")
            String id = "<"+include.getAttribute("href").substring("cid:".length())+">";
            Iterator<AttachmentPart> it = msg.getAttachments();
            while(it.hasNext()){
                AttachmentPart att = it.next();
                if(id.equals(att.getContentId())){
                    try {
                        data = att.getRawContentBytes();
                    } catch (SOAPException e) {
                        throw S1SystemError.wrap(e);
                    }
                    break;
                }
            }
        }else{
            String b = el.getTextContent();
            try{
                data = Base64.decode(b);
            } catch (Base64FormatException e) {
                throw S1SystemError.wrap(e);
            }
        }
        if(LOG.isDebugEnabled())
            LOG.debug("Reading file from SOAP, length: "+(data==null?-1:data.length));
        return data;
    }
236898
public static SoapAttachment parseAttachment(Element attachmentElement) {
        SoapAttachment soapAttachment = new SoapAttachment();

        if (attachmentElement.hasAttribute("content-id")) {
            soapAttachment.setContentId(attachmentElement.getAttribute("content-id"));
        }

        if (attachmentElement.hasAttribute("content-type")) {
            soapAttachment.setContentType(attachmentElement.getAttribute("content-type"));
        }

        if (attachmentElement.hasAttribute("charset-name")) {
            soapAttachment.setCharsetName(attachmentElement.getAttribute("charset-name"));
        }

        if (attachmentElement.hasAttribute("mtom-inline")) {
            soapAttachment.setMtomInline(Boolean.parseBoolean(attachmentElement.getAttribute("mtom-inline")));
        }

        if (attachmentElement.hasAttribute("encoding-type")) {
            soapAttachment.setEncodingType(attachmentElement.getAttribute("encoding-type"));
        }
        
        Element attachmentDataElement = DomUtils.getChildElementByTagName(attachmentElement, "data");
        if (attachmentDataElement != null) {
            soapAttachment.setContent(DomUtils.getTextValue(attachmentDataElement));
        }
        
        Element attachmentResourceElement = DomUtils.getChildElementByTagName(attachmentElement, "resource");
        if (attachmentResourceElement != null) {
            soapAttachment.setContentResourcePath(attachmentResourceElement.getAttribute("file"));
        }

        return soapAttachment;
    }
183434
public void addMessageToCache(Message message) {
        messages.compute(message.getId(), (key, value) -> {
            if ((value == null) || (value.get() == null)) {
                WeakReference<Message> result = new WeakReference<>(message, messagesCleanupQueue);
                messageIdByRef.put(result, key);
                return result;
            }
            return value;
        });
    }
697134
private static void setupFlowId(SoapMessage message) {
        String flowId = FlowIdHelper.getFlowId(message);

        if (flowId == null) {
            flowId = FlowIdProtocolHeaderCodec.readFlowId(message);
        }

        if (flowId == null) {
            flowId = FlowIdSoapCodec.readFlowId(message);
        }

        if (flowId == null) {
            Exchange ex = message.getExchange();
            if (null!=ex){
                Message reqMsg = ex.getOutMessage();
                if ( null != reqMsg) {
                    flowId = FlowIdHelper.getFlowId(reqMsg);
                }
            }
        }

        if (flowId != null && !flowId.isEmpty()) {
            FlowIdHelper.setFlowId(message, flowId);
        }
    }
1043015
public void setPayloadProperties(BaseMessage message, Object msg)
   {
       MessageDataDesc messageDataDesc = message.getMessageDataDesc(null);   // Top level only
       if (messageDataDesc != null)
       {
           Map<String,Class<?>> mapPropertyNames = messageDataDesc.getPayloadPropertyNames(null);
           if (mapPropertyNames != null)
           {
               for (String strKey : mapPropertyNames.keySet())
               {
                   Class<?> classKey = mapPropertyNames.get(strKey);
                   this.setPayloadProperty(message, msg, strKey, classKey);
               }
           }
       }
       if (message.get("Version") == null)
           this.setPayloadProperty(DEFAULT_VERSION, msg, "Version", Float.class);
       this.setPayloadProperty(this.getTimeStamp(), msg, "TimeStamp", org.joda.time.DateTime.class); // Current timestamp
   }
983992
public void setMessage(String message) {
        requireArgument(message != null && !message.isEmpty(), "Message cannot be null or empty.");
        this.message = message;
    }
105133
protected SOAPMessage createSoapRequest(Object requestObj) throws ActivityException {
        try {
            MessageFactory messageFactory = getSoapMessageFactory();
            SOAPMessage soapMessage = messageFactory.createMessage();
            Map<Name,String> soapReqHeaders = getSoapRequestHeaders();
            if (soapReqHeaders != null) {
                SOAPHeader header = soapMessage.getSOAPHeader();
                for (Name name : soapReqHeaders.keySet()) {
                    header.addHeaderElement(name).setTextContent(soapReqHeaders.get(name));
                }
            }

            SOAPBody soapBody = soapMessage.getSOAPBody();

            Document requestDoc = null;
            if (requestObj instanceof String) {
                requestDoc = DomHelper.toDomDocument((String)requestObj);
            }
            else {
                Variable reqVar = getProcessDefinition().getVariable(getAttributeValue(REQUEST_VARIABLE));
                XmlDocumentTranslator docRefTrans = (XmlDocumentTranslator)VariableTranslator.getTranslator(getPackage(), reqVar.getType());
                requestDoc = docRefTrans.toDomDocument(requestObj);
            }

            SOAPBodyElement bodyElem = soapBody.addBodyElement(getOperation());
            String requestLabel = getRequestLabelPartName();
            if (requestLabel != null) {
                SOAPElement serviceNameElem = bodyElem.addChildElement(requestLabel);
                serviceNameElem.addTextNode(getRequestLabel());
            }
            SOAPElement requestDetailsElem = bodyElem.addChildElement(getRequestPartName());
            requestDetailsElem.addTextNode("<![CDATA[" + DomHelper.toXml(requestDoc) + "]]>");

            return soapMessage;
        }
        catch (Exception ex) {
            throw new ActivityException(ex.getMessage(), ex);
        }
    }
1114395
public MessageBuilder addAttachment(BufferedImage image, String fileName) {
        delegate.addAttachment(image, fileName);
        return this;
    }
725011
void addNewMessage(JsMessageWrapper message, boolean isStored, boolean isRecoverable)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc,
                  "addNewMessage",
                  new Object[] { new Integer(hashCode()),
                                 message,
                                 new Boolean(isStored)});

    JsMessage jsMsg = message.getMessage();

    long id = jsMsg.getSystemMessageValue();
    SIBUuid8 uuid = jsMsg.getSystemMessageSourceUuid();

    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
      SibTr.debug(tc,
                  "addNewMessage",
                  new Object[] { new Integer(hashCode()),
                                 new Long(jsMsg.getSystemMessageValue()),
                                 jsMsg.getSystemMessageSourceUuid(),
                                 message,
                                 new Boolean(isStored)});

    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
      SibTr.debug(localConsumerPoint, tc, "verboseMsg OUT : " + message.getMessage().toVerboseString());

    synchronized(this)
    {
      LMEMessage newElement = null;
      long messageReferenceExpiry = messageProcessor.getCustomProperties().get_message_reference_expiry_value();

      // We have to create an object if the pool is empty
      if(pooledMsg == null)
      {
        newElement = new LMEMessage(id, uuid, message, isStored, isRecoverable, messageLockExpiry, messageReferenceExpiry);
      }
      // Otherwise pop the first pooled object and use that
      else
      {
        newElement = pooledMsg;
        pooledMsg = pooledMsg.next;
        newElement.next = null;
        pooledCount--;

        newElement.reuseMessage(id, uuid, message, isStored, isRecoverable, messageLockExpiry, messageReferenceExpiry);
      }

      // Add the message to the end of the list
      newElement.previous = lastMsg;
      if(lastMsg != null)
        lastMsg.next = newElement;
      else
        firstMsg = newElement;
      lastMsg = newElement;

      // If the locks are set to expire and this is the first message we need to
      // register an alarm
      if(messageLockExpiry != 0)
      {
        // If there are no other messages expiring, this will be the first one
        if(nextMsgToExpire == null)
          nextMsgToExpire = newElement;

        // If we don't have an alarm registered, register one now
        if(!alarmRegistered)
        {
          if(TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(tc, "addNewMessage", "Registering MessageLock Expiry alarm for: " + nextMsgToExpire);

          alarmManager.create(messageLockExpiry, this);
          alarmRegistered = true;
        }
      }

      if (messageReferenceExpiry != 0)
      {
        if (messageLockExpiry != 0 && messageReferenceExpiry > messageLockExpiry)
        {
          // The messageReferenceExpiry is greater than the messageLockExpiry. There is no
          // point in creating the alarm for messageReferenceExpiry as the message lock expiry
          // will always go first.
          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
          {
            SibTr.debug(tc, "MessageReferenceExpiry: "+messageReferenceExpiry+" is greater than messageLockExpiry: "+messageLockExpiry);
            SibTr.debug(tc, "MessageReferneceExpiry Alarm not registered");
          }
        }
        else
        {
          try
          {
            if (message.getReportCOD() == null)
            {
              // Now register the message reference expiry alarm
              // If there are no other message references expiring, this will be the first one
              if(nextMsgReferenceToExpire == null)
                nextMsgReferenceToExpire = newElement;

              // If we don't have an alarm registered, register one now
              if(!msgReferenceAlarmRegistered)
              {
                if(TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                  SibTr.debug(tc, "addNewMessage", "Registering MessageReference Expiry alarm for: " + nextMsgReferenceToExpire);

                alarmManager.create(messageReferenceExpiry, new MessageReferenceExpiryAlarm());
                msgReferenceAlarmRegistered = true;
              }
            }
          }
          catch(SIResourceException e)
          {
            // No FFDC code needed

            // There was a problem getting hold of the ReportCOD of the message
            // assume it is set and don't create the expiry alarm.
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
              SibTr.debug(tc, "Thrown exception when trying to create msg ref expiry alarm: " + e);
          }
        }
     }

      // By adding a message we must be about to call consumeMessages and therefore
      // we're in a valid state for calls
      validState = true;
    } // synchronized

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "addNewMessage", this);
  }
1024597
private void checkMessage(Message msg) throws MessagingException {
        if (msg == null) {
            throw new MessagingException("Message is null");
        }
        if (!(msg instanceof MimeMessage)) {
            throw new MessagingException(
                    "AWS Mail Service can only send MimeMessages");
        }
    }
1328175
public function addMessage(Message $message)
    {
        $message->setMessageBroker($this);
        $this->messages->attach($message);
    }
572121
public void setMessage(String message) {
    pushData.clear();
    Map<String, Object> map = AVUtils.createStringObjectMap("alert", message);
    pushData.put("data", map);
  }
1093967
public BaseMessage sendMessageRequest(BaseMessage messageOut)
    {
        if (m_con == null)
        {
            try {
                m_con = SOAPConnectionFactory.newInstance().createConnection();
            } catch(Exception e) {
                Utility.getLogger().warning("Unable to open a SOAPConnection");
                e.printStackTrace();
            }
        }
        String strTrxID = null;
        try {

            // Create a message from the message factory.
            SOAPMessage msg = null; //mf.createMessage();
            
            msg = this.setSOAPBody(msg, messageOut);
            
            // Create an endpoint for the recipient of the message.
            TrxMessageHeader trxMessageHeader = (TrxMessageHeader)messageOut.getMessageHeader();
            String strDest = (String)trxMessageHeader.get(TrxMessageHeader.DESTINATION_PARAM);
            String strMsgDest = (String)trxMessageHeader.get(TrxMessageHeader.DESTINATION_MESSAGE_PARAM);
            if (strMsgDest != null)
                strDest = strDest + strMsgDest;
            strTrxID = (String)trxMessageHeader.get(TrxMessageHeader.LOG_TRX_ID);

            URL urlEndpoint = new URL(strDest);
            // Send the message to the provider using the connection.
            // Create a message from the message factory.
            if (trxMessageHeader.get(SOAPMessage.WRITE_XML_DECLARATION) != null)
                msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, (String)trxMessageHeader.get(SOAPMessage.WRITE_XML_DECLARATION));    // true or [false]
            if (trxMessageHeader.get(SOAPMessage.CHARACTER_SET_ENCODING) != null)
                msg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, (String)trxMessageHeader.get(SOAPMessage.WRITE_XML_DECLARATION));    // [utf-8] or utf-16
            if (trxMessageHeader.get(CONTENT_TYPE) != null)
                msg.getMimeHeaders().setHeader(CONTENT_TYPE, (String)trxMessageHeader.get(CONTENT_TYPE)); // "text/xml"
            if (trxMessageHeader.get(SOAP_ACTION) != null)
                msg.getMimeHeaders().setHeader(SOAP_ACTION, (String)trxMessageHeader.get(SOAP_ACTION)); // Not recommended
            
        	//OutputStream out = new ByteArrayOutputStream();
        	//msg.writeTo(out);
        	//out.flush();
        	//Utility.getLogger().info(out.toString());

            strTrxID = this.logMessage(strTrxID, messageOut, MessageInfoTypeModel.REQUEST, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.SENT, null, null);

            SOAPMessage reply = m_con.call(msg, urlEndpoint);
// To test this locally, use the next two lines.
//            MessageReceivingServlet servlet = new MessageReceivingServlet();
//            SOAPMessage reply = servlet.onMessage(msg);

            if (reply != null)
            {
                BaseMessage messageReply = new TreeMessage(null, null);
                new SoapTrxMessageIn(messageReply, reply);
                return messageReply;
            } else {
                System.err.println("No reply");
            }
        } catch(Throwable ex) {
            ex.printStackTrace();
            String strErrorMessage = ex.getMessage();
            this.logMessage(strTrxID, messageOut, MessageInfoTypeModel.REQUEST, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.ERROR, strErrorMessage, null);
            return BaseMessageProcessor.processErrorMessage(this, messageOut, strErrorMessage);
        }            

        return null;
    }