Derik Whittaker



Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at
Mocking a Web Service Proxy

Today I finally had to create a mock of a web service proxy, what fun.  Of course the first go at it failed because I did not think about the fact that the web service proxy is NOT serializable.  This sucked, so what was I to do.

Well, fortunately for me web service proxy classes are partial’s, so I am able to ‘tweek’ the class.

Basically what I did was created a new partial class on my web service proxy as well as an interface for the partial class.  I then went in to my consuming code for the web service and modified it to use the interface, not the concrete class.  After these simple changes, I can now mock my web service when needed and use the actual at run time.

Creating the interface for my web service

Implementing the interface on my new partial class

Creating the test

BTW, if there is a better, easier way to do this, please let me know

kick it on

Posted 07-05-2007 8:09 AM by Derik Whittaker
Filed under: , , ,



Proxy Templates » Blog Archive » Proxy July 5, 2007 12:11 pm wrote Proxy Templates » Blog Archive » Proxy July 5, 2007 12:11 pm
on 07-25-2007 12:01 AM
ewdx wrote re: Mocking a Web Service Proxy
on 08-30-2007 10:37 AM


proxy script wrote re: Mocking a Web Service Proxy
on 02-21-2008 10:58 PM

Cool Stuff! Thanks

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)