I was having a similar problem, at least with Gmail contacts using CardDav. The problem is that CardDav puts your newly synced contacts in a separate "group" on your iphone than your current contacts. (You can check that by hitting "groups" in the upper left of your contacts and seeing what's listed there.) So for new contacts, yes, it will sync both ways, but not necessarily for old ones that were solely on your phone.
A couple of things to start with:
1. When you make a new contact on your iphone, does it properly sync with your gmail contacts online? (I think you say that it does, but I'm just checking.) If not, go to Settings->Mail, Contacts, Calendars->Default Account (the one under the Contacts section) and choose Google).
- Had you ever synced with gmail contacts in the past? Are the contacts that were in your iphone different from the ones in gmail, or are there duplicates?
Because CardDav does not touch the existing iphone contacts, there's no good way to get those to be in gmail. The only way I've found to do this is for each contact, choose "share" and email it to yourself. When you get the email on your phone, add it to your contacts. Then, assuming Google is the default (see #1 above), it'll put it in the right place and then all syncing will work as it should.
I agree that this is convoluted, but it's the best I can come up with after days of searching and messing around. I had previously synced with Gmail contacts using iTunes (no longer supported, as far as I can tell), so once I set up CardDav it downloaded all of my existing contacts, creating two of everything, but it at least knew enough to link them so they only show up once.
You'll have to specify exactly what the problem is with syncing calendars with CalDav. That's something I've actually had better luck with.