A mathematic model for pile-soil system is established. The method of characteristic lines to solve the stress wave equations is proposed considering the interactions of pile and soil.The optimization method can be used to quantitatively detect the faults in piles, where the soil parameters inversed from a model with complete pile are used to inverse the equivalent stress wave impedance for others with damaged piles and then identify their corresponding faults. Numerical examples of the simulation for experimental piles and of the detection for engineering piles show that the method gives the quite accurate results, especially for those with primary or secondary faults.