programming4us
programming4us
WEBSITE

Sharepoint 2010 : Creating a Pluggable Workflow Service (part 6) - Calling a SharePoint-Hosted WCF Service

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

3. Calling a SharePoint-Hosted WCF Service

To complete our calculation engine implementation, we need to add some code to our DemoCalculationEngine project. We need a method that can make a call into our SharePoint WCF service to notify the workflow that calculation is complete. With the SharePoint project deployed, we first need to add a service reference to the SharePoint WCF service.

  1. In the DemoCalculationEngine project, choose Project | Add Service Reference. Set the Address to http://localhost/_layouts/WorkflowDemonstration/CalculationResultService.svc.

  2. Since the service is hosted within SharePoint, requests must be authenticated; as a result, we need to enter credentials for a user account with permissions to connect to the SharePoint site.

  3. Once the service metadata has been retrieved, set the Namespace to CalculationResultService and the click OK to complete the process.

    Note

    When adding a service reference for a SharePoint, you’ll sometimes see multiple prompts to enter credentials. Usually, after entering valid credentials once, clicking Cancel on subsequent prompts will allow the process to continue.


  4. With our service reference in place, we can move on to add the following code to handle the button click event in Form1.cs:

    private void button1_Click(object sender, System.EventArgs e)
    {
    foreach (DataGridViewRow row in dataGridView1.SelectedRows)
    {
    CalculationResultService.CalculationResultServiceClient client = new
    CalculationResultService.CalculationResultServiceClient();
    client.ClientCredentials.Windows.AllowedImpersonationLevel =
    System.Security.Principal.TokenImpersonationLevel.Impersonation;
    CalculationResultService.CalculationResult result = new
    CalculationResultService.CalculationResult();

    CalculationRequest selected = row.DataBoundItem as CalculationRequest;

    result.Result = selected.ProductName + " Complete";
    result.InstanceId = selected.InstanceId;
    result.SiteId = selected.SiteId;
    result.WebId = selected.WebId;

    if (client.ProcessCalculationResult(result))
    {
    row.Selected = false;
    _calculationList.Remove(selected);
    }
    }
    }


We can now manually trigger calculation results by selecting an item from the data grid and then clicking the Send Result button.

Tip

When hosting WCF services in SharePoint, it’s important that the client proxy allows impersonation; otherwise, some weird and wonderful COM errors may be thrown by SharePoint. To allow impersonation, set the AllowedImpersonationLevel to Impersonation, as shown in the preceding code sample.

Other  
  •  PowerShell for SharePoint 2013 : Word Automation Services - Disable Word 97–2003 Document Scanning , Disable Embedded Fonts in Conversions
  •  PowerShell for SharePoint 2013 : Word Automation Services - Modify Job Monitoring, Modify Conversion Timeouts
  •  PowerShell for SharePoint 2013 : Word Automation Services - Configure Supported Document Formats for Conversion, Modify Database Information
  •  PowerShell for SharePoint 2013 : Word Automation Services - Configure the Conversion Processes, Configure Conversion Throughput
  •  ASP.NET 4 : Error Handling, Logging, and Tracing - Throwing Your Own Exceptions
  •  ASP.NET 4 : Error Handling, Logging, and Tracing - Handling Exceptions
  •  ASP.NET 4 : Error Handling, Logging, and Tracing - Exception Handling
  •  ASP.NET 4 : Error Handling, Logging, and Tracing - Common Errors
  •  Sharepoint 2010 : Designing a Workflow Using Visio 2010 (part 3) - Using Visio Services to Visualize Workflow State
  •  Sharepoint 2010 : Designing a Workflow Using Visio 2010 (part 2) - Implementing a Visio Workflow Using SharePoint Designer
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us