Using Biztalk 2010, ESB 2.1, WorkFlow, AppFabric or Azure as Middleware for message routing to Sharepoint BCS.
Share on FacebookMonthly Archives: November 2010
Integration Users Group KickOff Speech
Once I have re-edited the BizTalk Exposed endpoints to allow for Create, Update and Delete I will publish the source code.
Share on FacebookComposite Guidance for Integration (Alpha)
Sharepoint Client Object model access from WCF (SOA) service.
Customers.svc
<%@ ServiceHost Language=”C#” Debug=”true” Service=”MIA.Speech1.WcfService.Customers” CodeBehind=”Customers.svc.cs” %>
Customers.svc.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using MIA.Speech1.Helpers;
namespace MIA.Speech1.WcfService
{
public class Customers : ICustomers
{
public List GetAllCustomers() {
return ClientObjectModelHelper.GetAllCustomers();
}
public Customer GetCustomerByID(string id) {
return ClientObjectModelHelper.GetCustomerByID(id);
}
public List CreateCustomer(string lastName, string firstName, string email, string address1) {
Customer c = new Customer();
c.Address1 = address1;
c.LastName = lastName;
c.FirstName = firstName;
c.EmailAddress = email;
return ClientObjectModelHelper.CreateCustomer(c);
}
public bool UpdateEmailAddress(string id, string emailAddress)
{
Customer c = new Customer();
c.idBDC = id;
c.EmailAddress = emailAddress;
return ClientObjectModelHelper.UpdateEmailAddress(c);
}
public bool UpdateName(string id, string lastName, string firstName)
{
Customer c = new Customer();
c.idBDC = id;
c.LastName = lastName;
c.FirstName = firstName;
return ClientObjectModelHelper.UpdateEmailAddress(c);
}
}
}
ICustomers.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using MIA.Speech1.Helpers;
namespace MIA.Speech1.WcfService
{
[ServiceContract]
public interface ICustomers
{
[OperationContract]
List GetAllCustomers();
[OperationContract]
Customer GetCustomerByID(string id);
[OperationContract]
List CreateCustomer(string lastName, string firstName, string email, string address1);
[OperationContract]
bool UpdateEmailAddress(string id, string emailAddress);
[OperationContract]
bool UpdateName(string id, string lastName, string firstName);
}
}
Customer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace MIA.Speech1.Helpers
{
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class Customer
{
[DataMember]
public string idBDC { get; set; }
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
[DataMember]
public string EmailAddress { get; set; }
[DataMember]
public string Address1 { get; set; }
}
}
ClientObject Helper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint;
namespace MIA.Speech1.Helpers
{
public static class ClientObjectModelHelper
{
public static List GetAllCustomers()
{
using (ClientContext spContext = new ClientContext(ConstantsHelper.SPSiteURI))
{
spContext.AuthenticationMode = ClientAuthenticationMode.Default;
// To Show a list of lists
Web web = spContext.Web;
spContext.Load(web);
spContext.Load(web.Lists);
spContext.ExecuteQuery();
ListCollection ls = web.Lists;
StringBuilder sb = new StringBuilder();
foreach(List eachList in web.Lists)
{
sb.Append(String.Format(“[{0}]n”, eachList.Title));
}
string s = sb.ToString();
//Use CamlQuery to get just the item you want.
Microsoft.SharePoint.Client.List list = spContext.Web.Lists.GetByTitle(ConstantsHelper.CustomerListName);
ListItemCollection items = list.GetItems(new CamlQuery());
spContext.Load(items);
spContext.ExecuteQuery();
//A View
//query.ViewXml = String.Format(“{0}”,lastName);
//return (from a in items.AsEnumerable()
// select new Customer()
// {
// id = Int64.Parse(a.FieldValues[“id”].ToString()),
// EmailAddress = a.FieldValues[“EmailAddress”].ToString(),
// LastName = a.FieldValues[“LastName”].ToString(),
// FirstName = a.FieldValues[“FirstName”].ToString(),
// Address1 = a.FieldValues[“Address1”].ToString()
// }).ToList();
List lc = new List();
foreach(ListItem l in items)
{
Customer c = new Customer();
c.Address1 = l.FieldValues[“Address1”].ToString();
c.EmailAddress = l.FieldValues[“EmailAddress”].ToString();
c.FirstName = l.FieldValues[“FirstName”].ToString();
c.idBDC = l.FieldValues[“BdcIdentity”].ToString();
c.LastName = l.FieldValues[“LastName”].ToString();
lc.Add(c);
}
return lc;
}
}
public static Customer GetCustomerByID(string BDCIdentity)
{
using (ClientContext spContext = new ClientContext(ConstantsHelper.SPSiteURI))
{
Web web = spContext.Web;
spContext.Load(web);
spContext.Load(web.Lists);
spContext.ExecuteQuery();
Microsoft.SharePoint.Client.List list = spContext.Web.Lists.GetByTitle(ConstantsHelper.CustomerListName);
ListItemCollection items = list.GetItems(new CamlQuery());
spContext.Load(items);
spContext.ExecuteQuery();
Customer c = new Customer();
//LINQ doesnt seem to work properly.
//ListItem myCustomerItem = items.Where(b => b.FieldValues[“BdcIdentity”].ToString() == BDCIdentity).FirstOrDefault();
foreach (ListItem myCustomerItem in items)
{
if (myCustomerItem.FieldValues[“BdcIdentity”].ToString() == BDCIdentity)
{
c.idBDC = myCustomerItem.FieldValues[“BdcIdentity”].ToString();
c.EmailAddress = myCustomerItem.FieldValues[“EmailAddress”].ToString();
c.LastName = myCustomerItem.FieldValues[“LastName”].ToString();
c.FirstName = myCustomerItem.FieldValues[“FirstName”].ToString();
c.Address1 = myCustomerItem.FieldValues[“Address1”].ToString();
return c;
}
}
return c;
}
}
public static List CreateCustomer(Customer c)
{
using (ClientContext spContext = new ClientContext(ConstantsHelper.SPSiteURI))
{
Microsoft.SharePoint.Client.List list = spContext.Web.Lists.GetByTitle(ConstantsHelper.CustomerListName);
spContext.AuthenticationMode = ClientAuthenticationMode.Default;
spContext.ExecuteQuery();
ListItemCreationInformation newItem = new ListItemCreationInformation();
ListItem newCustomer = list.AddItem(newItem);
newCustomer[“Address1”] = c.Address1;
newCustomer[“EmailAddress”] = c.EmailAddress;
newCustomer[“LastName”] = c.LastName;
newCustomer[“FirstName”] = c.FirstName;
newCustomer.Update();
spContext.ExecuteQuery();
list.GetItems(new CamlQuery());
return GetAllCustomers();
}
}
public static bool UpdateEmailAddress(Customer c)
{
using (ClientContext spContext = new ClientContext(ConstantsHelper.SPSiteURI))
{
List list = spContext.Web.Lists.GetByTitle(ConstantsHelper.CustomerListName);
spContext.AuthenticationMode = ClientAuthenticationMode.Default;
CamlQuery query = CamlQuery.CreateAllItemsQuery(); ;
ListItemCollection listItems = list.GetItems(query);
// Should only take
spContext.Load(listItems, items => items.Where(a => a.FieldValues[“BdcIdentity”].ToString() == c.idBDC));
spContext.ExecuteQuery();
if (listItems.Count > 0)
{
//Should only be one returned.
listItems[0].FieldValues[“EmailAddress”] = c.EmailAddress;
listItems[0].Update();
spContext.ExecuteQuery();
listItems = list.GetItems(query);
spContext.Load(listItems, items => items.Where(a => a.FieldValues[“BdcIdentity”].ToString() == c.idBDC));
spContext.ExecuteQuery();
return listItems[0].FieldValues[“EmailAddress”].ToString() == c.EmailAddress;
}
return false;
}
}
public static bool UpdateName(Customer c)
{
using (ClientContext spContext = new ClientContext(ConstantsHelper.SPSiteURI))
{
List list = spContext.Web.Lists.GetByTitle(ConstantsHelper.CustomerListName);
spContext.AuthenticationMode = ClientAuthenticationMode.Default;
spContext.AuthenticationMode = ClientAuthenticationMode.Default;
CamlQuery query = CamlQuery.CreateAllItemsQuery(); ;
ListItemCollection listItems = list.GetItems(query);
// Should only take
spContext.Load(listItems, items => items.Where(a => a.FieldValues[“BdcIdentity”] == c.idBDC));
spContext.ExecuteQuery();
//Should only be one returned.
if (listItems.Count > 0)
{
listItems[0].FieldValues[“LastName”]= c.LastName;
listItems[0].FieldValues[“FirstName”] = c.FirstName;
listItems[0].Update();
spContext.ExecuteQuery();
listItems = list.GetItems(query);
spContext.Load(listItems, items => items.Where(a => a.FieldValues[“BdcIdentity”].ToString() == c.idBDC));
spContext.ExecuteQuery();
return listItems[0].FieldValues[“FirstName”].ToString() == c.FirstName && listItems[0].FieldValues[“LastName”].ToString() == c.LastName;
}
return false;
}
}
}
}
Building up a VM for Integration Development
I have a Dell 6510E with 8 GB of Ram I needed to use as a Work PC , and run VM’s for User Groups and Demo’s on. I have created this VM 2-3 times now and I think I have the steps down fairly solidly now. You may have a different take on this, however from my perspective building up the VM this way allows you to spend your time coding and not having to deal with minor errors here and there. My first run through without a domain created 20 hours of Troubleshooting multiple insignificant errors.
I will suggest if you are using MSDN to load these that you have software that will mount an ISO (Like MagicDisc).
Requirements:
- Server 2008 R2
- Proper Drivers installed (working NIC and Wireless)
- A decent amount of time.
- Wireless Lan Service Feature Enabled. (So you can connect to customer or worksite networks).
Steps
- Configure Static Address on Wired Port.
- In my home we use the standard 192.168.1.xxx/24 Addresses.
- Copy your DNS information down from your router.
- [Start]->Right Click [Network] -> [Properties]
- Then in top left Click [Change Adapter Settings]
- Right Click on your Wired Connection-> [Properties]
- My Settings:
- Go to Hyper-V Manager and click Virtual Network Manager [My Settings]:
- Create your Virtual Machine:
- In this Order:
- Run DC Promo to upgrade to a Domain. (Why you needed a static IP since AD machines need to run DNS and require a Static IP
- Install Visual Studio 2010 Custom setup [Uncheck Sql Server Express]
- Install SQL 2008 R2
- Install SharePoint 2010 (New Farm instance)
- Create User Groups for BizTalk:
- Install BizTalk changing the Groups from COMPUTER GROUPS to the Domain Groups you just Created.
- Install SharePoint 2010 Designer
- Install BizTalk ESB
- Setup Secure Store Service ID
- Setup ECT (In my case ECT SQL DB)
- Test DB to List
- Installed Silverlight 4 Tools for Visual Studio 2010
- Installed Windows Azure Tools for Microsoft Visual Studio.