| Tom Fry 2005-08-02, 6:02 pm |
| I'm trying to create a receive port & location through c# code. I've
borrowed some code from the MSDN samples(listed below). When I run the
snippet I get an error at root.SaveChanges(). The error is 'Could not
validate TransportTypeData, Address or Public properties for Receive Location
'Receive Location 1'. An invalid value property \"URI\*.*. I'm obviously
not setting the location correctly. Anyone know how I should be doing this?
private void CreateAndConfigureReceiveLocation()
{
BtsCatalogExplorer root = new BtsCatalogExplorer();
try
{
root.ConnectionString = "Integrated
Security=SSPI;database=BizTalkMgmtDb;ser
ver= YOURSERVER";
//First, create a new one way receive port.
ReceivePort myreceivePort = root.AddNewReceivePort(false);
//Note that if you dont set the name property for the receieve
port,
//it will create a new receive location and add it to the
receive //port.
myreceivePort.Name = "My Receive Port";
//Create a new receive location and add it to the receive port
ReceiveLocation myreceiveLocation =
myreceivePort.AddNewReceiveLocation();
foreach(ReceiveHandler handler in root.ReceiveHandlers)
{
if(handler.TransportType.Name == "HTTP")
{
myreceiveLocation.ReceiveHandler = handler;
break;
}
}
//Associate a transport protocol and URI with the receive
location.
foreach (ProtocolType protocol in root.ProtocolTypes)
{
if(protocol.Name == "HTTP")
{
myreceiveLocation.TransportType = protocol;
break;
}
}
myreceiveLocation.Address = "http://www.microsoft.com";
//Assign the first receive pipeline found to process the message.
foreach(Pipeline pipeline in root.Pipelines)
{
if(pipeline.Type == PipelineType.Receive)
{
myreceiveLocation.ReceivePipeline = pipeline;
break;
}
}
//Enable the receive location.
myreceiveLocation.Enable = true;
myreceiveLocation.FragmentMessages =
Fragmentation.Yes;//optional property
myreceiveLocation.ServiceWindowEnabled = false; //optional
property
//Try to commit the changes made so far. If the commit fails,
//roll-back all changes.
root.SaveChanges();
}
catch(Exception e)
{
root.DiscardChanges();
throw e;
}
}
|