static void EnlistParty() { // Create the root object and set the connection string BtsCatalogExplorer catalog = new BtsCatalogExplorer(); catalog.ConnectionString = "SERVER=.;DATABASE=BizTalkMgmtDb;Integrated Security=SSPI"; try { Party myParty = catalog.Parties["FedEx"]; // Search for the shipper role Role svcRole = null; foreach (Role role in catalog.Assemblies[0].Roles) { if (role.Name == "ShipperRole") { svcRole = role; break; } } // Enlist the party under the shipper role EnlistedParty enlistedParty = svcRole.AddNewEnlistedParty(myParty); enlistedParty.Mappings[0].SendPort = (SendPort)myParty.SendPorts[0]; // NormalDelivery enlistedParty.Mappings[1].SendPort = (SendPort)myParty.SendPorts[1]; // ExpressDelivery // Commit the changes catalog.SaveChanges(); } catch (Exception e) { catalog.DiscardChanges(); throw e; } }