Serialises the given object as a {@link StringEntity}.

@param requestMessage The object to be serialised.
@throws UnsupportedEncodingException If a serialisation error occurs.
320912
protected StringEntity serialiseRequestMessage(Object requestMessage) throws UnsupportedEncodingException {
        StringEntity result = null;

        // Add the request message if there is one
        if (requestMessage != null) {
            // Send the message
            String message = Serialiser.serialise(requestMessage);
            result = new StringEntity(message);
        }

        return result;
    }
1078263
private static JsJmsMessage decodeObjectBody(String body) throws MessageDecodeFailedException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "decodeObjectBody");
        JsJmsObjectMessage result = new JsJmsObjectMessageImpl(MfpConstants.CONSTRUCTOR_NO_OP);
        if (body != null)
            result.setSerializedObject(HexString.hexToBin(body, 0));
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "decodeObjectBody");
        return result;
    }
94973
private void decodeSubscription(ByteBuf in, SubscribeMessage message) throws UnsupportedEncodingException {
        String topic = Utils.decodeString(in);
        byte qos = (byte)(in.readByte() & 0x03);
        message.addSubscription(new SubscribeMessage.Couple(qos, topic));
    }
890578
public static byte[] serialize(Object obj, String errorMessage) {
    try {
      return serialize(obj);
    } catch (IOException e) {
      throw new RuntimeException(errorMessage, e);
    }
  }
207500
public static String serializeEncodedRequest(String username) {
    MiniMessagePack.Packer packer = new MiniMessagePack.Packer();
    packer.pack(1);
    packer.pack('q');
    packer.pack(username);
    return ASCIICodec.encode(packer.getBytes());
  }
989205
public void doWithMessage(WebServiceMessage requestMessage) throws IOException, TransformerException {
        endpointConfiguration.getMessageConverter().convertOutbound(requestMessage, message, endpointConfiguration, context);
    }
1310128
public void requestMsgs(int requestNumber, int receivedBytes, int requestedBytes)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "requestMsgs",
                                           new Object[]{requestNumber, receivedBytes, requestedBytes});

      SIErrorException e = new SIErrorException(
         nls.getFormattedMessage("PROTOCOL_ERROR_SICO2003", null,null)
      );

      FFDCFilter.processException(e, CLASS_NAME + ".requestMsgs",
                                  CommsConstants.CATCONSUMER_REQUESTMSGS_01,
                                  this);

      SibTr.error(tc, "PROTOCOL_ERROR_SICO2003", e);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "requestMsgs");

      // Re-throw this exception so that the client will informed if required
      throw e;
   }
109865
public BaseMessage sendMessageRequest(BaseMessage messageOut)
    {
        TrxMessageHeader trxMessageHeader = (TrxMessageHeader)messageOut.getMessageHeader();
        String strTrxID = (String)trxMessageHeader.get(TrxMessageHeader.LOG_TRX_ID);
        try {
            // Create a fake Incoming message with this message's external data
            String strMessageCode = (String)trxMessageHeader.get(LocalMessageTransport.LOCAL_PROCESSOR);
            TrxMessageHeader trxMessageHeaderIn = new TrxMessageHeader(null, null);
            trxMessageHeaderIn.put(TrxMessageHeader.MESSAGE_CODE, strMessageCode);

            BaseMessage messageIn = new TreeMessage(trxMessageHeaderIn, null);
            new ExternalMapTrxMessageIn(messageIn, messageOut.getExternalMessage().getRawData());
            // And fake send it by calling this:
            BaseMessage messageReply = this.processIncomingMessage(messageIn, null);
            this.logMessage(strTrxID, messageOut, MessageInfoTypeModel.REQUEST, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.SENT, null, null);

            this.setupReplyMessage(messageReply, null, MessageInfoTypeModel.REPLY, MessageTypeModel.MESSAGE_OUT);
            int iErrorCode = this.convertToExternal(messageReply, null);
            if (iErrorCode != DBConstants.NORMAL_RETURN)
            {
                String strMessageDescription = this.getTask().getLastError(iErrorCode);
                if ((strMessageDescription == null) || (strMessageDescription.length() == 0))
                    strMessageDescription = "Error converting to external format";
                messageReply = BaseMessageProcessor.processErrorMessage(this, messageOut, strMessageDescription);
            }

            return messageReply;
        } catch (Throwable ex)  {
            ex.printStackTrace();
            String strError = "Error in processing or replying to a message";
            Utility.getLogger().warning(strError);
            this.logMessage(strTrxID, null, MessageInfoTypeModel.REQUEST, MessageTypeModel.MESSAGE_OUT, MessageStatusModel.ERROR, strError, null);
            return BaseMessageProcessor.processErrorMessage(this, messageOut, strError);
        }
    }
762936
public void setMessageFormat(String messageFormat) {
        if (!"string".equals(messageFormat)
                && !"message".equals(messageFormat)) {
            throw new IllegalArgumentException("Unsupported message.format=" + messageFormat + ", only supported \"string\" or \"message\" format.");
        }
        this.messageFormat = messageFormat;
    }
1028424
def _AddSerializeToStringMethod(message_descriptor, cls):
  """"""

  def SerializeToString(self):
    # Check if the message has all of its required fields set.
    errors = []
    if not self.IsInitialized():
      raise message_mod.EncodeError(
          'Message %s is missing required fields: %s' % (
          self.DESCRIPTOR.full_name, ','.join(self.FindInitializationErrors())))
    return self.SerializePartialToString()
  cls.SerializeToString = SerializeToString
253832
@Override
    public ObjectMessage createObjectMessage() throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createObjectMessage");

        ObjectMessage objectMessage = null;

        try {
            objectMessage = jmsSession.createObjectMessage();
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createObjectMessage", new Object[] { objectMessage });
        }

        return objectMessage;

    }
348977
private HttpEntity populateEntity(RequestElements intuitRequest) throws FMSException {
        byte[] compressedData = intuitRequest.getCompressedData();

        if (null == compressedData) {
            // use postString to create httpEntity
            try {
                return new StringEntity(intuitRequest.getPostString());
            } catch (UnsupportedEncodingException e) {
                throw new FMSException("UnsupportedEncodingException", e);
            }
        }

        // use compressed data to create httpEntity
        return new InputStreamEntity( new ByteArrayInputStream(compressedData) , compressedData.length);
    }
988496
protected byte[] serialize(IMessage<ID, DATA> msg) {
        return msg != null ? SerializationUtils.toByteArray(msg) : null;
    }
1034284
public static byte[] serialize( AbstractMessage message , int typicalSize )
    {
        RawDataBuffer rawMsg = message.getRawMessage();
        if (rawMsg != null)
            return rawMsg.toByteArray();

        RawDataBuffer buffer = new RawDataBuffer(typicalSize);
        buffer.writeByte(message.getType());
        message.serializeTo(buffer);
        
        return buffer.toByteArray();
    }
1253120
public static Serializable deserialize(byte[] bytes, String errorMessage) {
    try {
      return deserialize(bytes);
    } catch (Exception e) {
      throw new RuntimeException(errorMessage, e);
    }
  }
125733
@Nonnull
  public static String getExpandedMessage (@Nonnull final String sMsg)
  {
    final char cCheck = sMsg.length () == 8 ? sMsg.charAt (7) : '\u0000';
    final String sUpce = sMsg.substring (0, 0 + 7);
    final byte nNumberSystem = _extractNumberSystem (sUpce);
    if (nNumberSystem != 0 && nNumberSystem != 1)
      throw new IllegalArgumentException ("Invalid UPC-E message: " + sMsg);

    final StringBuilder aSB = new StringBuilder ();
    aSB.append (Byte.toString (nNumberSystem));
    final byte nMode = StringParser.parseByte (sUpce.substring (6, 6 + 1), (byte) -1);
    if (nMode >= 0 && nMode <= 2)
    {
      aSB.append (sUpce.substring (1, 1 + 2));
      aSB.append (Byte.toString (nMode));
      aSB.append ("0000");
      aSB.append (sUpce.substring (3, 3 + 3));
    }
    else
      if (nMode == 3)
      {
        aSB.append (sUpce.substring (1, 1 + 3));
        aSB.append ("00000");
        aSB.append (sUpce.substring (4, 4 + 2));
      }
      else
        if (nMode == 4)
        {
          aSB.append (sUpce.substring (1, 1 + 4));
          aSB.append ("00000");
          aSB.append (sUpce.substring (5, 5 + 1));
        }
        else
          if (nMode >= 5 && nMode <= 9)
          {
            aSB.append (sUpce.substring (1, 1 + 5));
            aSB.append ("0000");
            aSB.append (Byte.toString (nMode));
          }
          else
          {
            // Shouldn't happen
            throw new IllegalArgumentException ("Internal error");
          }
    final String sUpcaFinished = aSB.toString ();
    final char cExpectedCheck = calcChecksumChar (sUpcaFinished, sUpcaFinished.length ());
    if (cCheck != '\u0000' && cCheck != cExpectedCheck)
      throw new IllegalArgumentException ("Invalid checksum. Expected " + cExpectedCheck + " but was " + cCheck);

    return sUpcaFinished + cExpectedCheck;
  }
1166023
private Entity<String> serialize(Object obj, String contentType) throws ClientErrorException {
        if (contentType.startsWith("application/json")) {
            try {
                return Entity.json(jsonMarshaller.serialize(obj));
            } catch (JsonMarshallingException e) {
                String msg = "Failed marshalling object to JSON data for sending to server: "+e.getMessage();
//                throw new ClientErrorException(Response.Status.BAD_REQUEST, e);
                throw new BadRequestServiceException(
                        new RestFaultInfo("BadRequest", Blame.CLIENT,
                                msg, ""+ ErrorCodes.Client.MARSHALLING_FAILED.getCode(),
                                null,
                                Retry.no(), Retry.no(),
                                Response.Status.BAD_REQUEST.getStatusCode(),
                                Response.Status.BAD_REQUEST.getReasonPhrase()
                        ), e
                );
            }
        } else {
            String msg = "Content type \"" + contentType + "\" is not supported.";
//            throw new NotSupportedException(msg);
            throw new BadRequestServiceException(
                    new RestFaultInfo("BadRequest", Blame.CLIENT,
                            msg, ""+ ErrorCodes.Client.UNSUPPORTED_TECHNOLOGY.getCode(),
                            null,
                            Retry.no(), Retry.no(),
                            Response.Status.BAD_REQUEST.getStatusCode(),
                            Response.Status.BAD_REQUEST.getReasonPhrase()
                    )
            );
        }
    }