none
How can I integrate HPC into an application with a UI while debugging with SOA Debugger [VS2010] RRS feed

  • Question

  • I have created a solution in Visual Studio 2010 with three projects:

    • EchoService - the WCF service from the sample code from the HPC R2 SDK,
    • EchoServiceClient - a new class library to which I added the service reference of EchoService, and the client code from "HelloWorldR2" that creates the session, sends and retrieves responses
    • EchoServiceUI - a user interface that calls EchoServiceClient. This is the SOA Debugger project (converted using SoaProjConverter) and the StartUp project.

    I found that only the project that is set as "StartUp Project" will cause the SOA debugger to deploy the service on to the nodes and connect the remote debugger. In this scenario, the job gets sent to the head node, and the work completes successfully, but no responses get returned. EchoServiceClient sits on "client.GetResponses<EchoResponse>()".

     

    If I have EchoServiceClient be the SOA Debugger project, as a console application, it works fine. This is the same as the EchoService sample application:

    • EchoService
    • EchoServiceClient - SOA Debugger project, set as StartUp project, console application. Deploys to the head node, and returns results.

     

    If I set EchoServiceClient as SOA Debugger, StartUp project, but as a class library

    • EchoService
    • EchoServiceClient - I start the project using F5 (Debug > Start Debugging). Deploy works successfully, and the job succeeds, but I get no responses back from the head node as in the first scenario.
    • EchoServiceUI - I start the UI by debugging a new instance.

     

    I can understand that the SOA Debugger only deploys if it is the StartUp project when debugging starts. I don't understand what could possibly be the difference between having a separate client project create the session and retrieve the responses vs. it being the same client. I would dearly appreciate any insights you all may have, or if you can point me towards sample code that may be what I'm trying to accomplish.

    Friday, July 1, 2011 7:15 AM

Answers

  • I found the solution: I had to call EchoServiceClient asynchronously from the windows forms client.
    • Marked as answer by krolley Friday, July 1, 2011 4:32 PM
    Friday, July 1, 2011 4:32 PM

All replies

  • Some follow up info. I have a solution as follows:

    • EchoService - WCF service from the HPC R2 SDK sample code
    • EchoServiceClient - a new class library that has HPC library references, and the service reference to EchoService. It creates a session, sends and retrieves responses.
    • ConsoleClient - a console project
    • FormsClient - a Windows Forms project

    ConsoleClient has a Main() method that simply calls EchoServiceClient.TestService(). This works fine.

    FormsClient has a Main() method that runs the form: Application.Run(new Form()). The constructor of Form1 calls EchoServiceClient.TestService(). This does not work.

    If I replace the line Application.Run(new Form1()) with EchoServiceClient.TestService() in the FormsClient, it also works fine. To me this means that I can't get any responses back from the broker node when running on the message loop for windows forms applications. Any ideas on why this could be? I can't seem to get any responses back from the broker node when starting from the UI.

    Friday, July 1, 2011 3:32 PM
  • I tried using Session.SetInterfaceMode(false, <handle of Form1>) but this has no effect. I do this before creating a DurableSession. Here is the full code, which is taken from the sample code:

     

    public static void TestService(IntPtr caller)
    {
      //change the headnode name here
      const string headnode = "EMEAWINHPC";
      const string serviceName = "EchoService";
      const int numRequests = 12;
          
      SessionStartInfo info = new SessionStartInfo(headnode, serviceName);
      Session.SetInterfaceMode(false, caller); //set interface mode to non console
          
      Console.WriteLine("Creating a session for EchoService...");
          
      using (DurableSession session = DurableSession.CreateSession(info))
      {
        Console.WriteLine("done session id = {0}", session.Id);
        NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport);
    
        using (BrokerClient<IService1> client = new BrokerClient<IService1>(session, binding))
        {
          Console.Write("Sending {0} requests...", numRequests);
          for (int i = 0; i < numRequests; i++)
          {
            EchoRequest request = new EchoRequest("hello world!");
            client.SendRequest<EchoRequest>(request, i);
          }
              
          client.EndRequests();
          Console.WriteLine("done");
    
          Console.WriteLine("Retrieving responses...");
    
          foreach (var response in client.GetResponses<EchoResponse>())
          {
            try
            {
              string reply = response.Result.EchoResult;
              Console.WriteLine("\tReceived response for request {0}: {1}", response.GetUserData<int>(), reply);
            }
            catch (Exception ex)
            {
              Console.WriteLine("Error occured while processing {0}-th request: {1}", response.GetUserData<int>(), ex.Message);
            }
          }
    
          Console.WriteLine("Done retrieving {0} responses", numRequests);
        }
    
        session.Close();
      }
    }
    


    Friday, July 1, 2011 4:17 PM
  • I found the solution: I had to call EchoServiceClient asynchronously from the windows forms client.
    • Marked as answer by krolley Friday, July 1, 2011 4:32 PM
    Friday, July 1, 2011 4:32 PM
  • Thank you, I had the same issue and that solution worked for me.
    Friday, September 4, 2015 9:21 AM