मैं एक सेवा का परीक्षण कैसे करूं जो वेब सेवा संदर्भ द्वारा उत्पन्न प्रॉक्सी क्लाइंट का उपयोग करता है?राइनो मोक्स के साथ डब्ल्यूसीएफ वेब सेवाओं का नकल कैसे करें
मैं क्लाइंट का नकल करना चाहता हूं, लेकिन जेनरेट किए गए क्लाइंट इंटरफ़ेस में बंद विधि नहीं है, जो प्रॉक्सी को ठीक से समाप्त करने के लिए आवश्यक है। यदि मैं इंटरफ़ेस का उपयोग नहीं करता, लेकिन इसके बजाय एक ठोस संदर्भ, मुझे नज़दीकी विधि तक पहुंच प्राप्त होती है लेकिन प्रॉक्सी को नकल करने की क्षमता को खो देता है।
public class ServiceAdapter : IServiceAdapter, IDisposable
{
// ILoggingServiceClient is generated via a Web Service reference
private readonly ILoggingServiceClient _loggingServiceClient;
public ServiceAdapter() : this(new LoggingServiceClient()) {}
internal ServiceAdapter(ILoggingServiceClient loggingServiceClient)
{
_loggingServiceClient = loggingServiceClient;
}
public void LogSomething(string msg)
{
_loggingServiceClient.LogSomething(msg);
}
public void Dispose()
{
// this doesn't compile, because ILoggingServiceClient doesn't contain Close(),
// yet Close is required to properly terminate the WCF client
_loggingServiceClient.Close();
}
}