wcf configuration for this code
- by user208081
I have the following code and would like to convert a lot of code into configuration settings for WCF. As you can see, the code is using wshttpbinding.
I appreciate any help on this.
try
{
// Provides a unique network address that a client uses to communicate with a service endpoint.
EndpointAddress endpointAddress = new EndpointAddress(new Uri(FAXServiceSettings.Default.FAXReceiveServiceURL));
// Specify the protocols, transports, and message encoders used for communication between the client and the service.
// WSHttpBinding represents an interoperable binding that supports distributed transactions and secure, reliable sessions.
// Spefically, SOAP message security is enabled for secure transmission of the message content.
WSHttpBinding clientBinding = new WSHttpBinding(SecurityMode.Message);
clientBinding.OpenTimeout = TimeSpan.FromSeconds(FAXServiceSettings.Default.FAXReceiveServiceOpenTimeoutInSeconds);
clientBinding.SendTimeout = TimeSpan.FromSeconds(FAXServiceSettings.Default.FAXReceiveServiceOpenTimeoutInSeconds);
// Use the ChannelFactory to enable the creation of channels to the binding and endpoint.
using (ChannelFactory<IReceiveFAX> channelFactory = new ChannelFactory<IReceiveFAX>(clientBinding, endpointAddress))
{
// Creates a channel of a specified type to a specified endpoint address.
IReceiveFAX channel = channelFactory.CreateChannel();
if (channel != null)
{
try
{
// Submit the FaxSchedule instance for routing.
channel.SubmitFAXForRouting(CreateNewFaxScheduleContainerInstance());
// Explicitly close the channel using the IClientChannel interface.
CloseChannel((channel as IClientChannel));
}
finally
{
// Explicitly dispose of the channel using IDisposable interface.
DisposeOfChannel((channel as IDisposable));
channel = null;
}
}
// This method causes a CommunicationObject to gracefully transition from any state, other than the Closed state, into the Closed state. The Close method allows any
// unfinished work to be completed before returning. For example, finish sending any buffered messages.
channelFactory.Close();
}
}
catch
{
throw;
}
Pratik