Is it possible to call a public method of a Workflow WebService from a Class  
Author Message
Satya vani





PostPosted: Windows Workflow Foundation, Is it possible to call a public method of a Workflow WebService from a Class Top

Hi

I am trying to call a webservice from workflow asynchronously. The response of the WebService will be in a class. I want to call the workflow webservice from that class and place the response in a public method.

I have added a webreference of the workflow webservice in that class, created an instance for that and trying to access the public method in that. But I am not able to access public method in workflow webservice.

Is there any way that I can call workflow webservice and access the public method in it. or is there any way that I can put my response(which is in a class) of the webservice (which is invoked asynchronously from a workflow) after some activities are executed.

Please help me anybody. Thanks in advance.




Software Development for Windows Vista7  
 
 
Nate of T





PostPosted: Windows Workflow Foundation, Is it possible to call a public method of a Workflow WebService from a Class Top

Satya, I just want to try to clarify what you are asking. At some points in your post it seems like you are trying to call a web service from a workflow and at other points you are trying to call a workflow which is exposed as a web service. You might even be trying to do both.

1) "The response of the WebService will be in a class." - What are you trying to say here What class are you referring to

2) By "place the response in a public method" are you saying that you would like to be able to call the web service and then later call some method to retrieve the response Are you looking for the asynchronous begin/end call pattern provided by the web service proxy class produced by WSDL.exe (and by extension, Add Web Reference)

3) What is the "public method in workflow webservice" that you are unable to access

4) When you say "is there any way that I can put my response of the webservice after some activities are executed", what does it mean to "put my response" Are you saying that you want to access it in the workflow Are you saying that you want to expose the result to the host

Your responses to these answers will help us give you good answers.



 
 
Satya vani





PostPosted: Windows Workflow Foundation, Is it possible to call a public method of a Workflow WebService from a Class Top

Hi Nate,

I am reframing my question.

I have a class from which I would like to call a method in a workflow which has been exposed as a webservice.

I have tried to call a method from a class by instantiating(created an object of) the Workflow exposed as Web Service, whereas I could not able to access any method in the workflow.

Ex:

Workflow exposed as WebService

WWFWS

{

Method1(string var1){}

}

Class

{

WWFWS obj = new WWFWS();

obj. // could not able to access Method1();

}

Your response is appreciated.

Thanks,

Satya



 
 
Nate of T





PostPosted: Windows Workflow Foundation, Is it possible to call a public method of a Workflow WebService from a Class Top

Okay, there is a step missing somewhere, but from the info above it could be any one of the following:

1) Possible Problem 1 - Method1 is NOT implemented as WebServiceInput and WebServiceOutput

Let's say your workflow is defined as follows:

public class Workflow1 : SequenceActivity
{
public void Method1(string var) {}
}

This will NOT result in a web method being created when the workflow is compiled. Instead, you should have workflow that is defined as follows:

<Workflow1>
<WebServiceInput MethodName="Method1"/>
</Workflow1>

When Workflow1 is compile we will create a class with a name like Workflow1_WebService which looks like:

public class Workflow1_WebService : WebService
{
[WebMethod]
public void Method1(string var) {}
}

I have left out several details about configuring WebServiceInput/Output activities because those are separate topics, but that is the gist.

2) Possible Problem 2 - Workflow has not been published as a web service

Since you mentioned that you added a web reference to your workflow in the original post I'm going to assume that this is not the problem. You have published your workflow as a web service, right You should be able to navigate to some address and see the standard web service pages.

3) Possible Problem 3 - The web service must be accessed through the proxy and NOT the web service class

As noted above we will generate a web service class in the workflow assembly when we see WebServiceInput/Output activities during compilation. You must use the proxy created by "Add Web Reference" to access the web service and NOT the Workflow1_WebService class that we generate.

--------

Hope this helps. Let me know if you have more questions.



 
 
Satya vani





PostPosted: Windows Workflow Foundation, Is it possible to call a public method of a Workflow WebService from a Class Top

I have published the workflow as webservice and using the proxy to access the web service..

I have used the webservice input/output activities but can you pls tell where exactly does the following code needs to be defined.

<Workflow1>
<WebServiceInput MethodName="Method1"/>
</Workflow1>

thanks,



 
 
Nate of T





PostPosted: Windows Workflow Foundation, Is it possible to call a public method of a Workflow WebService from a Class Top

The XML in my post does not need to be "defined" anywhere if you are using the WF Extensions for Visual Studio. If you create a Code Only project then by dragging and dropping activities onto the design surface you will cause us to generate programming model code behind the scenes in a designer file (exactly like Windows Forms). If you create a Code Separation project then you will get a .XOML file containing the XML that represents your designed workflow. I was merely using the XML as short-hand for describing a snippet of workflow that declares a single web method.

So, if you are using the WebServiceInput/Output activities and have published the workflow as a web service, then you are doing all of the right things.

Can you please show me your workflow definition (either the contents of the <workflowName>.DESIGNER.vb/cs file or the contents of the <workflowName>.XOML file)