A question that also comes up occasionally is how you can use an Agatha service from a client which isn’t aware of Agatha? Or more specifically: can an Agatha service be used from a client which has generated a proxy based on the WSDL of the Agatha service? The answer is yes ![]()
First of all, make sure your service exposes its metadata. You do this in the usual WCF fashion:
<behaviors>
<serviceBehaviors>
<behavior name="RequestProcessorBehavior">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances="500"/>
</behavior>
</serviceBehaviors>
</behaviors>
The serviceMetadata element with the httpGetEnabled=”true” attribute is the important one in the snippet above.
After that, you can simply generate a service proxy through visual studio or svcutil or whatever:
Now you can write the following code to communicate with your Agatha Service Layer:
using System;
using Sample.NonAgathaAwareClient.MyAgathaService;
namespace Sample.NonAgathaAwareClient
{
class Program
{
static void Main(string[] args)
{
using (var proxy = new MyAgathaService.WcfRequestProcessorClient())
{
var responses = proxy.ProcessRequests(new[] { new HelloWorldRequest() });
var helloWorldResponse = (HelloWorldResponse)responses[0];
Console.WriteLine(helloWorldResponse.Message);
Console.Read();
}
}
}
}
Notice that there are no Agatha-related using statements, nor is there any reference to Agatha or the assembly which contains the Request/Response types. All of the required data can be found within the WSDL and you can generate proxies for it just as you could with any other WCF service. The client-side usage model is of course as bad as it always is with standard WCF (for more information, be sure to read: Why I Dislike Classic Or Typical WCF Usage) but if you’re willing to put up with it, then at least you can ![]()
This also means that you should be able to generate service proxies for other platforms as well, as long as they support SOAP services.