Most likely, it happens bacause it is impossible to "Create a Web Part that interacts with a Web service or a Windows Communication Foundation (WCF) service." in sandboxed solutions[in sandboxed solutions][1].
As a workaround you can create full-trust proxy[full-trust proxy][2].
Some links which could be usefull:
- Walkthrough: Creating and Calling a Full-Trust Proxy Operation [Walkthrough: Creating and Calling a Full-Trust Proxy Operation][3]
- SharePoint 2010 Sandboxed soulutions: Full Trust Proxies [SharePoint 2010 Sandboxed soulutions: Full Trust Proxies][4] [1]: http://msdn.microsoft.com/en-us/library/ff798382.aspx [2]: http://msdn.microsoft.com/ru-ru/library/gg622616%28v=office.14%29.aspx [3]: http://msdn.microsoft.com/ru-ru/library/gg622617%28v=office.14%29.aspx [4]: http://blah.winsmarts.com/2009-12-SharePoint_2010_Sandboxed_Solutions__Full_Trust__Proxies.aspx
Hope it helps. If so, please press upvote and mark as answer :-).
Regards, Michael