Dynamics of long sea waves in the channels of variable depth and variable rectangular cross-section is discussed within various approximations -from the shallow water equations to those of nonlinear dispersion theory. General approach permitting to find traveling (non-reflective) waves in inhomogeneous channels is demonstrated within the framework of the shallow water linear theory. The appropriate conditions are determined by solving a system of ordinary differential equations. The so-called self-consistent channel in which the width is connected with its depth in a specific way is studied in detail. Within the linear theory of shallow water, a wave does not reflect from the bottom irregularities. The wave shape remains unchanged on the records of the wave gauges (mareographs) fixed along the channel axis, but it varies in space. Nonlinearity and dispersion lead to the wave transformation in such a channel. Within the framework of the shallow water weakly nonlinear theory, the wave shape is described by the Riemann solution, and the wave breaks (gradient catastrophe) quicker in the zones of decreasing depth. The modified Korteweg -de Vries equation describing evolution of a solitary wave of weak but finite amplitude in a self-consistent channel, the depth of which can vary arbitrary, is derived. Some examples of a solitary wave transformation in such a channel are analyzed (particularly, a soliton adiabatic transformation in the channel with the slowly varying parameters, and a solitary wave fission into the group of solitons after it has passed the zone where the depth changes abruptly. The obtained solutions extend the class of those represented earlier by S.F. Dotsenko and his colleagues.