Saturday, February 5, 2022
creating-a-wcf-client-part-4-programmatically-configuring-wcf-cl
Copy of this source for reference and personal use https://7thzero.com/blog/creating-a-wcf-client-part-4-programmatically-configuring-wcf-cl
Creating a WCF Client Part 4: Programmatically configuring WCF Clients
August 18th at 12:00am
While using the app.config file is a quick & convenient (Article 2, Article 3) way to get your WCF clients up and running, there are times when you may not want to distribute a .exe.config file alongside your EXE. This article describes how to configure a WCF client on-the-fly in your C# Code.
Here are the steps I took to convert one of my WCF Clients to use an on-demand configuration approach:
Open the WCF Client project in Visual Studio
Cut out the parts of the app.config file pertaining to web services (see Article #2 for an example) and paste them into a notepad document for reference
At this point we want to revise the basic client connection code from our earlier articles into something a little more specific.
As we have removed the client configuration settings from the app.config file, we need to:
Define a Binding
Needs a unique Name
A number of properties must be set
Define an Endpoint Address
Should have a unique Name
Needs a URI of the web service you want to hit
Instantiate the WCF Client object by constructor
Explicit Binding
Explicit Endpoint Address
Note: You can find all of the necessary settings for the Binding and Endpoint Address by looking through the sections of the app.config that you copied out in Step 2 above.
Our code goes from looking something like this:
// Instantiates a client object
SomeServiceClient client = new SomeServiceClient();
// Opens the client object
client.Open();
//
// Between the open & close, you would use any methods made available in the class.
// For example, if the client provided a method named ReturnDataTable which
// Returns a data table, you could do something like this:
DataTable results = client.ReturnDataTable();
// Closes the client object
client.Close();
To something that is a little more complex. I've added comments around the major sections for clarity:
// ----- Programmatic definition of the SomeService Binding -----
System.ServiceModel.BasicHttpBinding SomeServiceBinding = new System.ServiceModel.BasicHttpBinding();
SomeServiceBinding.Name = "SomeServiceServiceBinding";
SomeServiceBinding.CloseTimeout = new TimeSpan(0, 1, 0);
SomeServiceBinding.OpenTimeout = new TimeSpan(0, 1, 0);
SomeServiceBinding.ReceiveTimeout = new TimeSpan(0, 1, 0);
SomeServiceBinding.SendTimeout = new TimeSpan(0, 1, 0);
SomeServiceBinding.AllowCookies = false;
SomeServiceBinding.BypassProxyOnLocal = false;
SomeServiceBinding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
SomeServiceBinding.MaxBufferSize = 65536;
SomeServiceBinding.MaxBufferPoolSize = 524288;
SomeServiceBinding.MaxReceivedMessageSize = 65536;
SomeServiceBinding.MessageEncoding= System.ServiceModel.WSMessageEncoding.Text;
SomeServiceBinding.TextEncoding = System.Text.Encoding.UTF8;
SomeServiceBinding.TransferMode = System.ServiceModel.TransferMode.Buffered;
SomeServiceBinding.UseDefaultWebProxy = true;
SomeServiceBinding.ReaderQuotas.MaxDepth = 32;
SomeServiceBinding.ReaderQuotas.MaxStringContentLength = 8192;
SomeServiceBinding.ReaderQuotas.MaxArrayLength = 16384;
SomeServiceBinding.ReaderQuotas.MaxBytesPerRead = 4096;
SomeServiceBinding.ReaderQuotas.MaxNameTableCharCount = 16384;
SomeServiceBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
SomeServiceBinding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None;
SomeServiceBinding.Security.Transport.ProxyCredentialType = System.ServiceModel.HttpProxyCredentialType.None;
SomeServiceBinding.Security.Message.ClientCredentialType = System.ServiceModel.BasicHttpMessageCredentialType.UserName;
SomeServiceBinding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
// ----------- End Programmatic definition of the SomeServiceServiceBinding --------------
// ---------- Configure a Remote Address Manually ----------------
System.ServiceModel.EndpointAddress SomeServiceServerAddress = new
System.ServiceModel.EndpointAddress("https://someservices.mydomain.com:809/Services/SomeOtherServices.svc");
// -----------End configure remote address manually --------------
// ----------- Instantiate & Open the Client object ----------
SomeServiceClient client = new SomeServiceClient(SomeServiceBinding, SomeServiceServerAddress);
client.Open();
//
// Between the open & close, you would use any methods made available in the class.
// For example, if the client provided a method named ReturnDataTable which
// Returns a data table, you could do something like this:
DataTable results = client.ReturnDataTable();
// Close the client object
client.Close();
~Troubleshooting~
Configuration system failed to initialize
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
** Exception Text **
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section userSettings. (C:\Users\Administrator\AppData\Local\SomeCompany\SomeWCFClient.exe_Url_fwt2rqjtqtwa4i3g42pr3zwuekhsbjwz\1.7.6.0\user.config line 3)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e)
--- End of inner exception stack trace ---
You may need to remove the user.config file or the automatically generated "program name" folder for your executable from C:\Users\appdata\local\CompanyName (for Windows Server 2008 R2). It looks like settings from app.config can become cached here, and when the app starts again it receives a configuration it doesn't quite understand.
Thursday, August 26, 2021
MySQL: How to create Column if not exists?
https://dba.stackexchange.com/questions/169458/mysql-how-to-create-column-if-not-exists
SELECT count(*)
INTO @exist
FROM information_schema.columns
WHERE table_schema = 'mydatabase'
and COLUMN_NAME = 'mycolumn'
AND table_name = 'mytable' LIMIT 1;
set @query = IF(@exist <= 0, 'ALTER TABLE mydatabase.`mytable` ADD COLUMN `mycolumn` MEDIUMTEXT NULL',
'select \'Column Exists\' status');
prepare stmt from @query;
EXECUTE stmt;
Friday, July 16, 2021
Regular expression to find non-ascii characters in a large file in notepad++
Recently I face an issue while importing a large xml file because of a some invalid characters in XML content.
Since it is a large file, the regular expression search in notepad++ helps to find the non ascii characters.
[^\s\x20-\x7E]
Thanks to :https://notepad-plus-plus.org/ , https://stackoverflow.com/questions/43334055/notepad-remove-non-alpanumeric-characters
Friday, May 21, 2021
Articles reference
https://hbr.org/2005/10/the-hard-side-of-change-management
https://www.businesstoday.in/opinion/columns/6-billion---the-hidden-cost-of-90-day-notice-period-to-companies-economy/story/439603.html
Tuesday, November 19, 2019
Packages used while Converting .Net core 2.0 project to .netcore 3.0
Packages used while Converting .Net core 2.0 project to .netcore 3.0
Install-Package Microsoft.IdentityModel.Tokens -Version 5.6.0
Install-Package Microsoft.AspNetCore.Authentication.JwtBearer -Version 3.0.0-preview-19075-0444
Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4
services.AddMvc(option => option.EnableEndpointRouting = false);
Friday, July 19, 2019
ஆன்மிகம் : Subash Krishnasamy
Credits : https://www.facebook.com/voiceofsubashkrishnasamy
Original content from : https://www.facebook.com/voiceofsubashkrishnasamy/posts/2402044279863237
ஆன்மிகம் என்பதே நாம் காண்பதும் உணர்வதுமான அனைத்துக்கும் மனிதனுக்கும் உள்ள உறவு பற்றிய கண்ணோட்டமே!
அதை சிருஷ்டி என்பது ஆன்மிகம். ஆதாவது இத்தனைக்குமான அடிப்படை மூலமாக ஒரு சக்தி இருந்து இத்தனையையும் ஒழுங்குமுறையில் இயக்குகிறது. அதுதான் இறைவன் என்று சொல்கிறது!
ஆனால் இத்தனையும் ஒரு எல்லையில்லாப் பேரியக்கமும் அதனுள் அடங்கிய எண்ணற்ற வகையிலான இயக்கக்கூறுகளுமே என்கிறது நாத்திகம்.
அனைத்துமான பரமாத்மா அதனுள் அடங்கிய ஜீவாத்மாவாகிய நம்மை ஆட்டுவிப்பதால் உயர்தர்ம நெறிகளில் நின்று வாழ்ந்து பரமாத்மாவுடன் ஐக்கியமாவதே நம் கடமை என்கிறது ஆன்மிகம்!
ஆனால் பேரியக்கமும் உள்ளியக்கக்கூறுகளுமாக இயங்கும் அண்டத்தில் பூமியும் உயிரினங்களும் ஒரு இயக்கக்கூறே!
அதில் பரிணாம வளர்ச்சியால் முக்காலமும் பற்றி சிந்திக்கத் தெரிந்த இனமாகிய மனிதன் சக மனிதருடனும் சக உயிரினங்களுடனும் இயற்கையுடனும் இணக்கமாகவும் சுதந்திரம், சமத்துவம், சகோதரத்துவம் என்னும் உணர்வுகளுடன் உன்னத வாழ்வு வாழ்வதே வாழ்க்கை என்கிறது நாத்திகம்!
இந்த இரண்டு கண்ணோட்டங் களையும் மறுக்க முடியாது.
அதனால் என்னுடைய ஆன்மிகம் இந்த இரு கண்ணோட்டங்களையும் மறுப்பது இல்லை.
அண்டபேரண்டமான அனைத்துமானது பரம்பொருள்...
அதனுள் அடங்கியுள்ள உயிருள்ள உயிரற்ற அனைத்தும் அந்தப் பரம்பொருளின் உட்கூறுகள்...
அவை ஒவ்வொன்றும் ஒன்று இன்னொன்றாக ஓயாமல் மாறிக்கொண்டே இருக்கின்றன.
குறிப்பாக உயிருள்ளது உயிரற்றதாகவும் உயி ற்றது உயிருள்ளதாகவும் ஓயாமல் மாறிக்கொண்டுள்ள ஒரு கிரகத்தில் வாழ்ந்துகொண்டுள்ளோம்.
எதுவும் நிலையானது அல்ல.
அதனால் பரம்பொருளின் உட்கூறுகளில் ஒன்றான நாம் சக மனிதருடனும் சக உயிரினங்களுடனும் முரண்பட்டுப் போராடி அமைதியற்ற வாழ்வு வாழ்வதைவிட அனைவரையும் அனைத்தையும் நேசித்து அனைத்துக்கும் உதவி வாழ்வதே பரம்பொருளாகிய இறைவனுக்கு இணக்கமான வாழ்க்கை!
ஒன்றைப் படைக்கவும் தண்டிக்கவும் அன்பைப் பொழியவும் வெறுப்பை வளர்க்கவும் வேடமிடவும்
இறைவன் மனித குணம் படைத்த அந்நியன் அல்ல.
இறைவன் வேறு நாம் வேறு அல்ல.
நாம் இறைவனின் ஒரு அங்கம்!
நமது சிறப்பே, நாம் பின்பற்றும் அனைவருக்கும் பொருந்தும் உயர்தர்ம நெறிகளே இறைவனுடைய அங்கமாக நாம் அளிக்கும் பங்களிப்பு!
இதுதான் எனது ஆன்மிகம்!
Original content from : https://www.facebook.com/voiceofsubashkrishnasamy/posts/2402044279863237
ஆன்மிகம் என்பதே நாம் காண்பதும் உணர்வதுமான அனைத்துக்கும் மனிதனுக்கும் உள்ள உறவு பற்றிய கண்ணோட்டமே!
அதை சிருஷ்டி என்பது ஆன்மிகம். ஆதாவது இத்தனைக்குமான அடிப்படை மூலமாக ஒரு சக்தி இருந்து இத்தனையையும் ஒழுங்குமுறையில் இயக்குகிறது. அதுதான் இறைவன் என்று சொல்கிறது!
ஆனால் இத்தனையும் ஒரு எல்லையில்லாப் பேரியக்கமும் அதனுள் அடங்கிய எண்ணற்ற வகையிலான இயக்கக்கூறுகளுமே என்கிறது நாத்திகம்.
அனைத்துமான பரமாத்மா அதனுள் அடங்கிய ஜீவாத்மாவாகிய நம்மை ஆட்டுவிப்பதால் உயர்தர்ம நெறிகளில் நின்று வாழ்ந்து பரமாத்மாவுடன் ஐக்கியமாவதே நம் கடமை என்கிறது ஆன்மிகம்!
ஆனால் பேரியக்கமும் உள்ளியக்கக்கூறுகளுமாக இயங்கும் அண்டத்தில் பூமியும் உயிரினங்களும் ஒரு இயக்கக்கூறே!
அதில் பரிணாம வளர்ச்சியால் முக்காலமும் பற்றி சிந்திக்கத் தெரிந்த இனமாகிய மனிதன் சக மனிதருடனும் சக உயிரினங்களுடனும் இயற்கையுடனும் இணக்கமாகவும் சுதந்திரம், சமத்துவம், சகோதரத்துவம் என்னும் உணர்வுகளுடன் உன்னத வாழ்வு வாழ்வதே வாழ்க்கை என்கிறது நாத்திகம்!
இந்த இரண்டு கண்ணோட்டங் களையும் மறுக்க முடியாது.
அதனால் என்னுடைய ஆன்மிகம் இந்த இரு கண்ணோட்டங்களையும் மறுப்பது இல்லை.
அண்டபேரண்டமான அனைத்துமானது பரம்பொருள்...
அதனுள் அடங்கியுள்ள உயிருள்ள உயிரற்ற அனைத்தும் அந்தப் பரம்பொருளின் உட்கூறுகள்...
அவை ஒவ்வொன்றும் ஒன்று இன்னொன்றாக ஓயாமல் மாறிக்கொண்டே இருக்கின்றன.
குறிப்பாக உயிருள்ளது உயிரற்றதாகவும் உயி ற்றது உயிருள்ளதாகவும் ஓயாமல் மாறிக்கொண்டுள்ள ஒரு கிரகத்தில் வாழ்ந்துகொண்டுள்ளோம்.
எதுவும் நிலையானது அல்ல.
அதனால் பரம்பொருளின் உட்கூறுகளில் ஒன்றான நாம் சக மனிதருடனும் சக உயிரினங்களுடனும் முரண்பட்டுப் போராடி அமைதியற்ற வாழ்வு வாழ்வதைவிட அனைவரையும் அனைத்தையும் நேசித்து அனைத்துக்கும் உதவி வாழ்வதே பரம்பொருளாகிய இறைவனுக்கு இணக்கமான வாழ்க்கை!
ஒன்றைப் படைக்கவும் தண்டிக்கவும் அன்பைப் பொழியவும் வெறுப்பை வளர்க்கவும் வேடமிடவும்
இறைவன் மனித குணம் படைத்த அந்நியன் அல்ல.
இறைவன் வேறு நாம் வேறு அல்ல.
நாம் இறைவனின் ஒரு அங்கம்!
நமது சிறப்பே, நாம் பின்பற்றும் அனைவருக்கும் பொருந்தும் உயர்தர்ம நெறிகளே இறைவனுடைய அங்கமாக நாம் அளிக்கும் பங்களிப்பு!
இதுதான் எனது ஆன்மிகம்!
Wednesday, February 6, 2019
Links to ORM Sample
Dapper | Dapper ORM Tutorial | Dapper Documentation
https://dapper-tutorial.net/dapper
https://docs.devexpress.com/XPO/3264/concepts/basics-of-creating-persistent-objects-for-existing-data-tables
https://docs.devexpress.com/XPO/2256/getting-started/tutorial-1-your-first-data-aware-application-with-xpo
http://docs.oasis-open.org/odata/new-in-odata/v4.0/cn01/new-in-odata-v4.0-cn01.html
Subscribe to:
Posts (Atom)