开发者

Working with web services

I'm developing an .NET application (WinForms, .NET Framework 4.0) and i need to call a method from a web service.

The probl开发者_如何转开发em is that the client's web service is only accessible from inside its network. So at development time, i can't access it, so I can add it as a refference.

How should I proceed?

Should I create some kind of replica of that web service in my network? Which would be the best option?


I'd get the WSDL and write a mock of it that i can call from my side.

I'd then make it return data that i was expecting and then later on have it return data that i wasn't expecting.

Then when you deploy it (should) be ok but you would need to run some integration tests.

The alternative it to tell them to open a port for you to use so that you can write the s/ware.


You could replicate the web service which returns dummy data.


I would wrap the call to the service in a separate abstraction layer, this would allow you to provide a different implementation if you wish during testing.

Eg. Something along the lines of..

public interface IXYZServiceInvoker
{
   SomeData SomeServiceCall();
}    

public class SomeServiceInvoker : IXYZServiceInvoker
{
   public void SomeServiceCall()
   {
             //Calls a real service    
   }        
}    

public class FakeServiceInvoker : IXYZServiceInvoker
{
    public SomeData SomeServiceCall()
    {
             //returns some dummy/test data    
    } 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜