MSDN > 論壇首頁 > Windows Azure > How to communicate a NORMAL workflow running in the cloud to a WCF service running on premise using .NET Service Bus
發問發問
 

問題How to communicate a NORMAL workflow running in the cloud to a WCF service running on premise using .NET Service Bus

所有回覆

  • 2009年7月6日 上午 08:23SANMI 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Can anybody help me ? I need to use this...
  • 2009年7月6日 上午 10:19Yi-Lun LuoMSFT, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    Hello, sorry I don't have time to write a step by step tutorial. But I have just created another sample. You can get it from http://cid-4722d155fb172dbb.skydrive.live.com/self.aspx/Public/Azure/AzureWFServiceBus.zip.

    To use it, please update your solution name and password in the following places:

    In Service project, update app.config:

    <

    userNamePassword userName="solution" password="password"/>

    In Service project, update Program.cs:

     

    Uri uri = ServiceBusEnvironment.CreateServiceUri("http", "solution", "EchoService");

    In the AzureWFServiceBus_WebRole project, update web.config:

    <

    endpoint name="BasicHttpBinding_IEchoService" address="http://solution.servicebus.windows.net/EchoService/" binding="basicHttpBinding" contract="Workflow.IEchoService"/>

    If you want to test the SimpleClient (a console client to make sure the service bus works), also modify the Program.cs:

     

    EndpointAddress address = new EndpointAddress("http://solution.servicebus.windows.net/EchoService/");

     

    The solution consists of the following projects:

    • Service: A simple service exposed to service bus. It contains an echo contract with both input and output.
    • SimpleClient: A simple client to test if the service bus works. You can ignore it.
    • Workflow: The workflow library.
    • AzureWFServiceBus: The cloud service project.
    • AzureWFServiceBus_WebRole: The web role project.

    One additional note to the suggestions in your original post: I found it is very difficult to control thread signals in an aspx page. So rather than write a simple aspx page, I'm writing a WCF service in the web role, and use an AJAX client to call the service.

    By the way, I would suggest you to learn how to use all the related technologies, such as WF, before trying to combine so many technologies.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
  • 2009年7月6日 下午 05:02SANMI 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Thank you Yi-Lun Luo, but your result is always null. Why? Workflow client (Service.svc) has this.result = "Server echos:  x" but resultDiv.innerHTML = "null".

    And another question, why is EchoContract.cs necessary in Workflow project? Can I use a reference to service interfaz?

  • 2009年7月7日 上午 03:30Yi-Lun LuoMSFT, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    From your description, it seems the WCF service was invoked and the workflow completes correctly. Then can you try to add a break point in the JavaScript's echo_Complete function? Is the result parameter correct?

    For your second question, you'll need to expose a metadata endpoint in your service project. Then you can add a service reference to the service project from your workflow project. But that essentially creates the contract interface together with a client proxy class for you, which will result in even more code. Since you don't need to invoke the service in your code, I think it's not necessary for you to add a service reference.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
  • 2009年7月7日 上午 07:50SANMI 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Ok!! Echo_Complete result parameter is null. I don't know if it's the reason:

    In Default.aspx:
            tempuri.org.IService.Echo(messageTextBox.value, echo_Complete);

    In the Service:
            public string Echo(string message)
            {
                WorkflowRuntime workflowRuntime = (WorkflowRuntime)HttpContext.Current.Application["WorkflowRuntime"];
                Dictionary<string, object> parms = new Dictionary<string, object>();
                parms.Add("Message", message);
                workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted);
                WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(Workflow.EchoWorkflow), parms);
                int i = Thread.CurrentThread.ManagedThreadId;
                workflowInstance.Start();
                this.waitHandle.WaitOne(60000);
                return this.result;      ---------------------------> This.result = null
            }
  • 2009年7月7日 上午 07:56Yi-Lun LuoMSFT, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    One potential cause is 1 minute has passed, but the workflow has not completed yet. You can try to set -1 instead of 60000 as the parameter to WaitOne, so it will wait forever unless another thread signals it to continue. Also, try to set two break points. One in workflowRuntime_WorkflowCompleted, and the other in Echo, after WaitOne. The break point in workflowRuntime_WorkflowCompleted should hit first. Is this the behavior you got?


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
  • 2009年7月7日 上午 08:50SANMI 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    With "this.waitHandle.WaitOne(60000);", it depends on the speed of the connection whether it returns the correct result or null. But when I debug with "this.waitHandle.WaitOne(-1);", I can see that it does three times workflowRuntime_WorkflowCompleted before doing "return this.result;" of Echo. When it does this line, in the third time this.result = null (before, this.result was the correct result). It's a strange behavior!!!
  • 2009年7月7日 上午 10:03Yi-Lun LuoMSFT, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Sorry, I forgot you need to remove the event handler after the workflow completes, or an extra handler will be added in the next request...

     

    this.waitHandle.WaitOne(-1);

    workflowRuntime.WorkflowCompleted -=

    new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted);

     

    return this.result;



    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
  • 2009年7月7日 下午 04:24SANMI 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Once your code is correct I have changed my code how you have done but in Default.aspx:

    tempuri.org.IService.Echo(messageTextBox.value, echo_Complete);    ->    tempuri.org.IService.CheckContractCompleteness(contractTextBox.value, validation_Complete);


    I have this error or warning in a windows:   "Microsoft JScript runtime error: 'tempuri' is undefined".

    I can't use tempori, why?
  • 2009年7月8日 上午 04:21Yi-Lun LuoMSFT, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Can you download the js file: http://127.0.0.1:81/Service.svc/jsdebug, and verify if namespace is corrct? In my sample, I'm not adding any xml namespaces to the WCF service, so tempuri.org.IService is used. Also can you make sure the js file is downloaded by your client?
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
  • 2009年7月8日 下午 04:05SANMI 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    I don't have jsdebug in my project but I can see it in your project, do you know why?

    Today all my service bus project (your project included) do this error, do you know why too?

    The socket transfer timed out after 00:00:54.0630000. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout.
  • 2009年7月9日 上午 02:54Yi-Lun LuoMSFT, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Have you updated your SDK to the July CTP? Please upgrade and try again. While there's no break changes other than Workflow Service is removed, old SDK may have some problems to work with the new release.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
  • 2009年7月9日 下午 04:05SANMI 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Thanks, it's crazy this SDK update form.


    I will repeat this question because the problem goes on:

          I don't have jsdebug in my project but I can see it in your project, do you know why?

    Thank you!

  • 2009年7月10日 上午 02:20Yi-Lun LuoMSFT, 版主使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     

    This file is generated at runtime. Do you have an AJAX Enabled WCF Service? Please following the instructions on http://msdn.microsoft.com/en-us/library/bb514961.aspx to see how to expose a WCF service to AJAX clients. Alternatively, you can just use Visual Stuio's "AJAX Enabled WCF Service" item template, which will perform all the tasks foryou.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.