使用 WCF 通道模型通过 Siebel 适配器对业务组件运行操作
本部分演示如何使用使用 Siebel 创建通道中创建的通道对 Siebel 执行操作。
// create binding
SiebelBinding binding = new SiebelBinding();
//set up an endpoint address
EndpointAddress address = new EndpointAddress("siebel://Username=myuser;Password=mypass@mysiebelserver:1234?SiebelObjectManager=SSEObjMgr&SiebelEnterpriseServer=ent771&Language=enu");
//create request channel factory
IChannelFactory<IRequestChannel> factory = binding.BuildChannelFactory<IRequestChannel>(new BindingParameterCollection());
//open factory
factory.Open();
//create request channel using endpoint
IRequestChannel channel = factory.CreateChannel(address);
//open the channel
channel.Open();
// send request message and receive reply
System.Xml.XmlReader readerIn = System.Xml.XmlReader.Create(inputXml);
System.ServiceModel.Channels.Message messageIn = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Default,action,readerIn);
System.ServiceModel.Channels.Message messageOut = channel.Request(messageIn);
// get response XML from SOAP message
System.Xml.XmlReader readerOut = messageOut.GetReaderAtBodyContents();
// save output file
XmlDocument doc = new XmlDocument();
doc.Load(readerOut);
doc.Save(outputXml);
Console.WriteLine("XML written out to {0}", outputXml);
// close the channel and the factory
channel.Close();
factory.Close();