void CIMOperationRequestEncoder::handleEnqueue()
{
    Message* message = dequeue();

    if (!message)
	return;

    _authenticator->setRequestMessage(message);

    switch (message->getType())
    {
	case CIM_CREATE_CLASS_REQUEST_MESSAGE:
	    _encodeCreateClassRequest(
		(CIMCreateClassRequestMessage*)message);
	    break;

	case CIM_GET_CLASS_REQUEST_MESSAGE:
	    _encodeGetClassRequest((CIMGetClassRequestMessage*)message);
	    break;

	case CIM_MODIFY_CLASS_REQUEST_MESSAGE:
	    _encodeModifyClassRequest(
		(CIMModifyClassRequestMessage*)message);
	    break;

	case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE:
	    _encodeEnumerateClassNamesRequest(
		(CIMEnumerateClassNamesRequestMessage*)message);
	    break;

	case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE:
	    _encodeEnumerateClassesRequest(
		(CIMEnumerateClassesRequestMessage*)message);
	    break;

	case CIM_DELETE_CLASS_REQUEST_MESSAGE:
	    _encodeDeleteClassRequest(
		(CIMDeleteClassRequestMessage*)message);
	    break;

	case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
	    _encodeCreateInstanceRequest(
		(CIMCreateInstanceRequestMessage*)message);
	    break;

	case CIM_GET_INSTANCE_REQUEST_MESSAGE:
	    _encodeGetInstanceRequest((CIMGetInstanceRequestMessage*)message);
	    break;

	case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
	    _encodeModifyInstanceRequest(
		(CIMModifyInstanceRequestMessage*)message);
	    break;

	case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:
	    _encodeEnumerateInstanceNamesRequest(
		(CIMEnumerateInstanceNamesRequestMessage*)message);
	    break;

	case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:
	    _encodeEnumerateInstancesRequest(
		(CIMEnumerateInstancesRequestMessage*)message);
	    break;

	case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
	    _encodeDeleteInstanceRequest(
		(CIMDeleteInstanceRequestMessage*)message);
	    break;

	case CIM_SET_QUALIFIER_REQUEST_MESSAGE:
	    _encodeSetQualifierRequest(
		(CIMSetQualifierRequestMessage*)message);
	    break;

	case CIM_GET_QUALIFIER_REQUEST_MESSAGE:
	    _encodeGetQualifierRequest(
		(CIMGetQualifierRequestMessage*)message);
	    break;

	case CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE:
	    _encodeEnumerateQualifiersRequest(
		(CIMEnumerateQualifiersRequestMessage*)message);
	    break;

	case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE:
	    _encodeDeleteQualifierRequest(
		(CIMDeleteQualifierRequestMessage*)message);
	    break;

	case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:
	    _encodeReferenceNamesRequest(
		(CIMReferenceNamesRequestMessage*)message);
	    break;

	case CIM_REFERENCES_REQUEST_MESSAGE:
	    _encodeReferencesRequest(
		(CIMReferencesRequestMessage*)message);
	    break;

	case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:
	    _encodeAssociatorNamesRequest(
		(CIMAssociatorNamesRequestMessage*)message);
	    break;

	case CIM_ASSOCIATORS_REQUEST_MESSAGE:
	    _encodeAssociatorsRequest(
		(CIMAssociatorsRequestMessage*)message);
	    break;

	case CIM_EXEC_QUERY_REQUEST_MESSAGE:
	    _encodeExecQueryRequest(
		(CIMExecQueryRequestMessage*)message);
	    break;

	case CIM_GET_PROPERTY_REQUEST_MESSAGE:
	    _encodeGetPropertyRequest((CIMGetPropertyRequestMessage*)message);
	    break;

	case CIM_SET_PROPERTY_REQUEST_MESSAGE:
	    _encodeSetPropertyRequest((CIMSetPropertyRequestMessage*)message);
	    break;

	case CIM_INVOKE_METHOD_REQUEST_MESSAGE:
	    _encodeInvokeMethodRequest(
		(CIMInvokeMethodRequestMessage*)message);
	    break;
    }

    //ATTN: Do not delete the message here.
    //
    // ClientAuthenticator needs this message for resending the request on
    // authentication challenge from the server. The message is deleted in
    // the decoder after receiving the valid response from thr server.
    //
    //delete message;
}
void CIMOperationRequestEncoder::handleEnqueue()
{
    Message* message = dequeue();

    if (!message)
        return;

    _authenticator->setRequestMessage(message);

    //
    // Encode request as binary request.
    //

    if (_binaryRequest)
    {
        CIMOperationRequestMessage* msg =
            dynamic_cast<CIMOperationRequestMessage*>(message);

        if (msg)
        {
            Buffer buf;

            if (BinaryCodec::encodeRequest(buf, _hostName,
                _authenticator->buildRequestAuthHeader(), msg, _binaryResponse))
            {
                _sendRequest(buf);
                return;
            }

            // Drop through and encode as an XML request below.
        }
    }

    //
    // Encode request as an XML request.
    //

    switch (message->getType())
    {
        case CIM_CREATE_CLASS_REQUEST_MESSAGE:
            _encodeCreateClassRequest(
                (CIMCreateClassRequestMessage*)message);
            break;

        case CIM_GET_CLASS_REQUEST_MESSAGE:
            _encodeGetClassRequest((CIMGetClassRequestMessage*)message);
            break;

        case CIM_MODIFY_CLASS_REQUEST_MESSAGE:
            _encodeModifyClassRequest(
                (CIMModifyClassRequestMessage*)message);
            break;

        case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE:
            _encodeEnumerateClassNamesRequest(
                (CIMEnumerateClassNamesRequestMessage*)message);
            break;

        case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE:
            _encodeEnumerateClassesRequest(
                (CIMEnumerateClassesRequestMessage*)message);
            break;

        case CIM_DELETE_CLASS_REQUEST_MESSAGE:
            _encodeDeleteClassRequest(
                (CIMDeleteClassRequestMessage*)message);
            break;

        case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
            _encodeCreateInstanceRequest(
                (CIMCreateInstanceRequestMessage*)message);
            break;

        case CIM_GET_INSTANCE_REQUEST_MESSAGE:
            _encodeGetInstanceRequest((CIMGetInstanceRequestMessage*)message);
            break;

        case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
            _encodeModifyInstanceRequest(
                (CIMModifyInstanceRequestMessage*)message);
            break;

        case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:
            _encodeEnumerateInstanceNamesRequest(
                (CIMEnumerateInstanceNamesRequestMessage*)message);
            break;

        case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:
            _encodeEnumerateInstancesRequest(
                (CIMEnumerateInstancesRequestMessage*)message);
            break;

        case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
            _encodeDeleteInstanceRequest(
                (CIMDeleteInstanceRequestMessage*)message);
            break;

        case CIM_SET_QUALIFIER_REQUEST_MESSAGE:
            _encodeSetQualifierRequest(
                (CIMSetQualifierRequestMessage*)message);
            break;

        case CIM_GET_QUALIFIER_REQUEST_MESSAGE:
            _encodeGetQualifierRequest(
                (CIMGetQualifierRequestMessage*)message);
            break;

        case CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE:
            _encodeEnumerateQualifiersRequest(
                (CIMEnumerateQualifiersRequestMessage*)message);
            break;

        case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE:
            _encodeDeleteQualifierRequest(
                (CIMDeleteQualifierRequestMessage*)message);
            break;

        case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:
            _encodeReferenceNamesRequest(
                (CIMReferenceNamesRequestMessage*)message);
            break;

        case CIM_REFERENCES_REQUEST_MESSAGE:
            _encodeReferencesRequest(
                (CIMReferencesRequestMessage*)message);
            break;

        case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:
            _encodeAssociatorNamesRequest(
                (CIMAssociatorNamesRequestMessage*)message);
            break;

        case CIM_ASSOCIATORS_REQUEST_MESSAGE:
            _encodeAssociatorsRequest(
                (CIMAssociatorsRequestMessage*)message);
            break;

        case CIM_EXEC_QUERY_REQUEST_MESSAGE:
            _encodeExecQueryRequest(
                (CIMExecQueryRequestMessage*)message);
            break;

        case CIM_GET_PROPERTY_REQUEST_MESSAGE:
            _encodeGetPropertyRequest((CIMGetPropertyRequestMessage*)message);
            break;

        case CIM_SET_PROPERTY_REQUEST_MESSAGE:
            _encodeSetPropertyRequest((CIMSetPropertyRequestMessage*)message);
            break;

        case CIM_INVOKE_METHOD_REQUEST_MESSAGE:
            _encodeInvokeMethodRequest(
                (CIMInvokeMethodRequestMessage*)message);
            break;

        default:
            // Unexpected message type
            PEGASUS_ASSERT(0);
            break;
    }

    //ATTN: Do not delete the message here.
    //
    // ClientAuthenticator needs this message for resending the request on
    // authentication challenge from the server. The message is deleted in
    // the decoder after receiving the valid response from thr server.
    //
    //delete message;
}