segunda-feira, 18 de novembro de 2013

Microsoft Workflow Manager - (400) Bad Request, 401.2 - Unauthorized



Os eventos abaixo ocorrem normalmente se o Workflow Manager foi reinstalado e/ou mal configurado:

1.

[...]
Microsoft.Workflow.Client.InvalidRequestException: The scope '/SharePoint/default/60b9a4e6-c9c4-46eb-b23e-fd2f63479c8d/76cb7003-0d67-4168-a4db-3698fc642d22' has no workflows under it. HTTP headers received from the server - ActivityId: d951e13a-d566-47e0-b7d4-ef6fe76d2ec0. NodeId: contoso. Scope: /SharePoint/default/60b9a4e6-c9c4-46eb-b23e-fd2f63479c8d/76cb7003-0d67-4168-a4db-3698fc642d22. Client ActivityId : a7aa559c-ffb6-6089-58d6-173f140b4e1a. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
[...]

2.

[...]
Microsoft.Workflow.Client.AuthenticationException: A response was returned that did not come from the Workflow Manager. Status code = 401:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  <html xmlns="http://www.w3.org/1999/xhtml">  <head>  <title>IIS 8.0 Detailed Error - 401.2 - Unauthorized</title>
[...]

A solução depende da causa, entretanto existem duas formas para resolver isto:

1. Re-registrar o Workflow Manager, por meio do seguinte comando:

Register-SPWorkflowService –SPSite http://intranet.contoso.com –WorkflowHostUri http://wfserver:12291 –AllowOAuthHttp -scopename SharePoint -force

2. Este script recria o escopo, altera as permissões e registra o WFM (deveria ser executado, se o evento numero 2 continua a ocorrer):

$ScopeUri = http://SERVER:12291/SharePoint
$Scope = SharePoint
$mycredentials = Get-Credential("DOMAIN\WFAPPPOOLUSER")
$SecurityConfig = New-Object Microsoft.Workflow.Client.Security.WindowsSecurityConfiguration("All Users")
$SecurityConfig.WorkflowAdminGroupName = "Users"

Get-SPWorkflowServiceApplicationProxy | Remove-SPServiceApplicationProxy
Remove-WFScope –ScopeUri $ScopeUri
Register-SPWorkflowService –SPSite "http://intranet.contoso.com" –WorkflowHostUri $ScopeUri –AllowOAuthHttp -scopename $Scope -force
Set-WFScopeSecurity -ScopeUri $ScopeUri -Credential $mycredentials -SecurityConfiguration $SecurityConfig

Register-SPWorkflowService http://technet.microsoft.com/pt-br/library/jj663115.aspx
Remove-WFScope http://msdn.microsoft.com/pt-br/library/windowsazure/jj193255(v=azure.10).aspx
Set-WFScopeSecurity http://msdn.microsoft.com/pt-br/library/windowsazure/jj193229(v=azure.10).aspx

[]


Nenhum comentário:

Postar um comentário