How to attach outlet box in soffit?
It's going to depend on what material is covering the soffit.
Soffit Covers
If it's aluminium/plastic soffit covers, you'll have to remove the section where you're installing the receptacle.  Install proper bracing (a simple 2x4 between the rafters should be fine), and attach the electrical box to it. Then mark, and cut a hole for the electrical box in the soffit cover. Finish by putting the soffit cover back in place.
Make sure to measure and align the box properly, so the box will be flush with (or just protruding from) the soffit cover.
Wood
If it's wood, you can either surface, or flush mount the electrical box. Simply select the appropriate box for your installation.
Weatherproofing and Ground-fault protection
Because the receptacle is outside, you'll want to provide ground-fault protection.  You'll also want to make sure the box, and cover are both weatherproof and approved for damp/wet locations. See this answer, to the question How do I install a receptacle in the soffit? for more information.