retif
retif

Reputation: 1642

Client's method description for WCF service

I have a WCF service (hosted in windows-service) and a client for it.

They interact as follows: client sends a request, service gets it and returns HTTP 200. Also client passes its address for the answer in the WS-Addressing header. For the moment that's all

After a few hours windows-service should send a result for that request. Client has a web-method that will get the result. So the question is: where should be a description (name of the method, its parameters) for the client's method that will get the result? Should the client expose its WSDL, or should I put that description in my WSDL (if it works that way)?

Upvotes: 0

Views: 415

Answers (1)

Tim
Tim

Reputation: 28530

As I understand your scenario, you have two services, let's call them Service A (hosted in a Windows Service) and Service B. Service B sends a request to Service A (in other words, it's acting like a client) to have Service A start a long-running task of some sort.

When the task is complete, Service A needs to send the results to Service B. Since it's a long-running task, using a duplex binding would not be ideal. However, Service A could call a method exposed by Service B to send the results.

Something like this:

[ServiceContract]
public interface IServiceA
{

    [OperationContract]
    public void StartWork();
}

[ServiceContract]
public interface IServiceB
{

    [OperationContract]
    public void ReceiveResults(ResultData data);
}

where ResultData is some object containing the results (could be a simple type as well, this is simply for illustration). ServiceA's StartWork can return void (the response will still be sent to the client, since it's not marked as IsOneWay=true). Semi-pseduo code follows:

Start the task:

ServiceAClient client = new ServiceAClient();
client.Open();
client.StartWork();
client.Close();

Service A sends the results to Service B when the task is complete:

ResultData results = new ResultData();
ServiceBClient client = new ServiceBClient();
client.Open();
client.ReceiveResults(results);
client.Close();

In this case, the method to receive the results will be part of Service B's WSDL, as Service A will call that method.

Upvotes: 2

Related Questions