Workflow Service application - IIS hosting
Today - we are going to talk about hosting workflow service application on IIS.
Recently, I came across a case where customer wanted to host the workflow service application on IIS with windows authentication enabled. We need to ensure we follow the inherited concepts of WCF service application configuration and hosting.
Create workflow service application
- Open Visual studio 2013 (or your version of visual studio)
- Create new solution
- Select Workflow Service Application project template
- Name the project as WorkflowService1
- Select Service1.xamlx
- Right click > View code
- Keep a note of Name value – it would be utilized in the service application endpoint configuration
- Go to Service1.xamlx and select ReceiveRequest
- As highlighted, IService is the service contract over here with GetData as the operation contract. It could also be your respective project specific names as well.
- Select Service1.xamlx and it should have following properties
- Ensure that custom tool must be select to MSBuild:Compile value. It would ensure that the workflow service component would be available as part of the implemented assembly.
- Now – select SendResponse of Service1.xamlx
- Click on View message… of Content row
- Modify your message data
- Go to web.config
<system.serviceModel> <services> <service name="Service1" behaviorConfiguration="behavior1"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="secured" contract="IService" name="mySerivceEP" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="behavior1"> <serviceMetadata httpsGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <bindings> <basicHttpBinding> <binding name="secured"> <security mode="Transport"> <transport clientCredentialType="Windows"/> </security> </binding> </basicHttpBinding> </bindings> </system.serviceModel>
- Build the project
- Publish the application to IIS (you can follow your own method)
- Right click WorkflowService1 project and go to Properties
- Go to Web tab and update like the following:
- Go to IIS manager and the respective virtual directory
- Go to Features view
- Select Authentication under IIS
- Ensure only Windows authentication is selected as you are trying enforce windows authentication
- Disable the default Anonymous authentication
- Browse the service component or wsdl
- You should be able to browse it
How to test
- Go to Visual studio Developer command prompt
- Open wcftestclient.exe
- Click Add service from menu
- Provide the workflow service wsdl in it
- Hit OK
- Click on method and test
I hope this helps - Happy Coding!!!