// // Disclaimer: // // DTN grants you an nonexclusive copyright license to use this code and you can // use it to prepare similar functions tailored to your own needs. // // The code is provided for illustrative purposes only and has not been tested under // all conditions. For that reason, DTN provides this code to you "AS IS" without // any warranties of any kind. // using pxweb.dtn.telvent.com; using System.ServiceModel; // PXWeb access wrapper class PXWeb { // PXWeb URL private const string PXWEB_URL = "https://pxweb.dtn.com/PXWebSvc/PXServiceDto.svc/WsHttpAddress"; // Channel and client objects to access PXWeb private ChannelFactory channelFactory; private IPXServiceDto client; // Constructor public PXWeb() { // Create the binding WSHttpBinding binding = new WSHttpBinding(); // Configure the binding binding.Security.Mode = SecurityMode.None; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; // Set large message size limits when expecting large results binding.ReaderQuotas.MaxStringContentLength = 1048576; binding.MaxReceivedMessageSize = 1048576; // Get the channel factory EndpointAddress endpointAddress = new EndpointAddress( PXWEB_URL ); this.channelFactory = new ChannelFactory( binding, endpointAddress ); // Create the channel this.client = channelFactory.CreateChannel(); } // Return the client public IPXServiceDto getClient() { return this.client; } // Close access to PXWeb public void close() { // Close the channel IClientChannel channel = (IClientChannel) this.client; channel.Close(); // Close the ChannelFactory this.channelFactory.Close(); } } // Test class class Test { // Main program static void Main() { // Open access to PXWeb PXWeb pxweb = new PXWeb(); // Prepare request object GetMinuteHistoryDto request = new GetMinuteHistoryDto() { UserID="YOUR_USER", Password="YOUR_PASSWORD", Interval="300", Symbol="+C`##,+S`##", StartTime="01-09-2012 09:30", EndTime="01-09-2012 13:45" }; // Call GetMinuteHistory and print response as a string string xml = pxweb.getClient().GetMinuteHistory( request ); System.Console.WriteLine( xml ); // Close access to PXWeb pxweb.close(); } }