Answered by:
configuring IIS to host service as xoml file.

Question
-
http://msdn.microsoft.com/en-us/library/bb412182.aspx
this page gives info on configuring a workflow as a WCF service using the XOML file rather than a compiled dll. I have not been able to get scenario 2 or 3 to work using the Calculator sample app as described. I have been unable to find any more information or samples or labs or demos on these 2 configurations to help me figure out what the problem is.
(on Vista SP1, IIS 7)
I have gotten scenario 1 - host a pre-compiled workflow definition as a service in IIS - to work, getting the "You have created a service." info page.
When I configure scenario 3 using the xoml file, I get this error:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
[NullReferenceException: Object reference not set to an instance of an object.]
System.Workflow.Activities.ServiceOperationHelpers.GetContracts(Type contractType) +46
System.Workflow.Activities.ReceiveActivity.System.ServiceModel.Description.IServiceDescriptionBuilder.BuildServiceDescription(ServiceDescriptionContext context) +154
....snip...I should see the "You have created a service." info page, right?
(files are (copied from ms page)):
Service.svc:
<%@ServiceHost language=c# Debug="true" Service="Calculator.xoml" Factory="System.ServiceModel.Activation.WorkflowServiceHostFactory" %>
web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<!-- Service name is workflow Name -->
<service name="StateMachineCalculatorService" behaviorConfiguration="ServiceBehavior" >
<endpoint address=""
binding="customBinding"
bindingConfiguration="basicHttpCookieBinding"
contract="Microsoft.WorkflowServices.Samples.ICalculator" />
<endpoint address="ContextOverHttp"
binding="wsHttpContextBinding"
contract="Microsoft.WorkflowServices.Samples.ICalculator" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<windowsAuthentication
allowAnonymousLogons="false"
includeWindowsGroups="true" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="basicHttpCookieBinding">
<context contextExchangeMechanism="HttpCookie" />
<textMessageEncoding messageVersion="Soap11" />
<httpTransport authenticationScheme="Ntlm" />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
<system.web>
<compilation>
<assemblies>
<add assembly="System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</system.web>
</configuration>Can anyone point me to more information on this configuration?
Also, no mention is made in the article of what to do with the code-behind .cs file. Including it in the vdir did not seem to change anything.
TIA,
Wednesday, December 3, 2008 8:18 PM
Answers
-
does your svc file have both the service attribute, with the path to your XOML files, and the codebehind attribute pointing to your service. Something like ~/app_code/myservice.cs ?
Again, with the pure XOML, I don't think the build provider for XOML will compile or look for class files. If the class for your root activity is included in the web app and built, then it should work, but if the class is not already built, the XOML won't be able to be deserialized into an object graph.Matt
See What You Can Learn -- http://www.pluralsight.com/courses/AppliedWF.aspx- Marked as answer by Kavita Kamani - MSFTMicrosoft employee, Moderator Tuesday, December 23, 2008 11:01 PM
Thursday, December 11, 2008 4:39 PM -
Also, if you are just getting the XOML file back from the server, it seems like some configuration is not right on your IIS. have you ensured that the ASP.NET version is correct in the vdir settings in IIS? Can you see the script mapping from xoml to the system.servicemodel.activation.httphandler?
Matt
See What You Can Learn -- http://www.pluralsight.com/courses/AppliedWF.aspx- Proposed as answer by edhickey Thursday, December 18, 2008 1:52 AM
- Marked as answer by Kavita Kamani - MSFTMicrosoft employee, Moderator Tuesday, December 23, 2008 11:00 PM
Thursday, December 11, 2008 4:48 PM
All replies
-
Have you tried running workflow service registration tool (WFServicesReg.exe)?
Go to http://msdn.microsoft.com/en-us/library/bb924408.aspx for more details about this tool. Let me know whether this helps.
Wednesday, December 10, 2008 2:01 AM -
The 2nd and 3rd scenarios are really intended for declarative workflows, i.e. with no code behind, so I'm not sure you're going to get what you want if you have a code file.
One thing to watch out for is the service name in the web.config ties to the Name attribute on the root element in the xoml file.
<sequentialworkflowactivity name="myservice" . . .
<service name="myservice" . . .
Also, make sure the library where your contracts exist is in the bin directory for the web app so it can be resolved at runtime.
Matt
Wednesday, December 10, 2008 6:00 PM -
Did not change anything. Still get the object reference error.
Expanded my testing to a Win2003 server runnning IIS 6.0: [I ran the WFServicesReg.exe tool here also]
Scenario 2 - xoml file => server just sends the xoml file and browser displays the text.
Scenario 3 - svc+xoml file => get the object reference error
[Scenario 1 - works]
The msdn page says nothing about the code-behind files but they have to be there somewhere to provide the complete behavior for the StateMachineCalculatorService workflow. So in scenario 3, I put the StateMachineCalculatorService.xoml.cs file in an App_Code directory and I could get the "You have created a service" test page occasionally. Actually the sequence was:
http://hdq-builddv-001/statemachinecalculatorservice/ - got directory listing denied (as expected)
http://hdq-builddv-001/statemachinecalculatorservice/Service.svc - got "You have created a service" test page
press refresh button - get object reference error
the above sequence was very repeatable, the only time I saw the test page was after using the URL w/o the Service.svc file.
If I open the browser and go straight to http://hdq-builddv-001/statemachinecalculatorservice/Service.svc - I get the object reference error reliably.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] System.Workflow.Activities.ServiceOperationHelpers.GetContracts(Type contractType) +46 System.Workflow.Activities.ReceiveActivity.System.ServiceModel.Description.IServiceDescriptionBuilder.BuildServiceDescription(ServiceDescriptionContext context) +154 System.ServiceModel.Description.<>c__DisplayClass1.<BuildServiceDescription>b__0(Walker w, WalkerEventArgs args) +38 System.Workflow.ComponentModel.Walker.Walk(Activity seedActivity, Boolean walkChildren) +170 System.Workflow.ComponentModel.Walker.Walk(Activity seedActivity) +6 System.ServiceModel.Description.DescriptionCreator.BuildServiceDescription(IDictionary`2& implementedContracts, IList`1& reflectedContracts) +188 System.ServiceModel.WorkflowServiceHost.CreateDescription(IDictionary`2& implementedContracts) +44 System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +152 System.ServiceModel.WorkflowServiceHost.InitializeDescription(WorkflowDefinitionContext workflowDefinitionContext, UriSchemeKeyedCollection baseAddresses) +27 System.ServiceModel.WorkflowServiceHost..ctor(WorkflowDefinitionContext workflowDefinitionContext, Uri[] baseAddress) +51 System.ServiceModel.Activation.WorkflowServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +546 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +516 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +42 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479 [ServiceActivationException: The service '/StateMachineCalculatorService/service.svc' cannot be activated due to an exception during compilation. The exception message is: Object reference not set to an instance of an object..] System.ServiceModel.AsyncResult.End(IAsyncResult result) +11527194 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Also, the web.config file for scenario 2 and 3 needs to contain the workflow compiler references or you get a compilation error. The msdn page should be updated accordingly if we ever figure out how to make this work.
TIA
Wednesday, December 10, 2008 8:13 PM -
does your svc file have both the service attribute, with the path to your XOML files, and the codebehind attribute pointing to your service. Something like ~/app_code/myservice.cs ?
Again, with the pure XOML, I don't think the build provider for XOML will compile or look for class files. If the class for your root activity is included in the web app and built, then it should work, but if the class is not already built, the XOML won't be able to be deserialized into an object graph.Matt
See What You Can Learn -- http://www.pluralsight.com/courses/AppliedWF.aspx- Marked as answer by Kavita Kamani - MSFTMicrosoft employee, Moderator Tuesday, December 23, 2008 11:01 PM
Thursday, December 11, 2008 4:39 PM -
Also, if you are just getting the XOML file back from the server, it seems like some configuration is not right on your IIS. have you ensured that the ASP.NET version is correct in the vdir settings in IIS? Can you see the script mapping from xoml to the system.servicemodel.activation.httphandler?
Matt
See What You Can Learn -- http://www.pluralsight.com/courses/AppliedWF.aspx- Proposed as answer by edhickey Thursday, December 18, 2008 1:52 AM
- Marked as answer by Kavita Kamani - MSFTMicrosoft employee, Moderator Tuesday, December 23, 2008 11:00 PM
Thursday, December 11, 2008 4:48 PM