Existing methods for handling routing and dimensioning in dynamic WDM networks solve the two problems separately. The main drawback of this approach is that a global minimum cost solution cannot be guaranteed. Given that wavelengths are costly resources, determining the minimum network cost is of fundamental importance. We propose an approach which jointly solves the routing and dimensioning problems in optical burst switching (OBS) networks, guaranteeing a target blocking per connection. The method finds the set of routes and the number of wavelengths per network link that minimise the total network cost. To accomplish this, an integer linear programming problem is solved. The proposed method was applied to ring networks, where the optimal solution achieves a reduction in the network cost of 10–40% (for traffic loads <0.4, compared to solving both problems separately). In the case of mesh topologies, to reduce the computational complexity of the method, we applied a variation of it which achieves a local minimum. Even so, a reduction of 5–20% (for traffic loads <0.4) in the network cost was obtained. This ability to lower network cost could make the proposed method the best choice to date for dynamic network operators.