<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>{ Duane.Wingett } - XML</title>
    <link>http://www.duanewingett.info/</link>
    <description>.Net Code Monkey</description>
    <language>en-gb</language>
    <copyright>Duane Wingett</copyright>
    <lastBuildDate>Sat, 12 Apr 2008 19:03:24 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>mail@duanewingett.info</managingEditor>
    <webMaster>mail@duanewingett.info</webMaster>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=f40ec3ec-6713-43ec-8007-f3b4ade7b1d8</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,f40ec3ec-6713-43ec-8007-f3b4ade7b1d8.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,f40ec3ec-6713-43ec-8007-f3b4ade7b1d8.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=f40ec3ec-6713-43ec-8007-f3b4ade7b1d8</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I'm sure many of you are aware that you can override the connection string settings
in your <strong>DataAccess</strong> layer of your web application with connection
string settings in your <strong>Web.Config</strong>. We found this out recently and
found it very useful in an intranet application at work recently. However this week
one of the other developers required that he could override a setting the <strong>BusinessEntity</strong> layer
of his application from the <strong>App.Config</strong> in the console layer.
</p>
        <p>
A quick chat with Mr Google didn't turn up a solution for this, so with this in mind
all three of us quickly tried to return a working solution. I'm going to try to give
an example of what we did, incase it something others may find of use. First we create
a solution with two class library projects within it. The first will simulate the <strong>DataAccess</strong> layer
and the second will simulate the <strong>BusinessEntity</strong> layer in an application.
In the <strong>BusinessEntity</strong> project we will create a reference to the <strong>DataAccess</strong> project.
</p>
        <p>
Starting with the <strong>DataAccess</strong> project we will add an <strong>App.Config</strong> file
by creating a setting called "MySetting" in the <strong>Settings</strong> tab
of the project <strong>Properties</strong>. The setting scope will be set to
Application.
</p>
        <p>
          <img src="http://www.duanewingett.info/content/binary/ConfigurationOverride_Settings.jpg" border="0" />
        </p>
        <p>
This creates a new <strong>sectionGroup</strong> called <strong>applicationSettings</strong> and
a new section in the <strong>App.Config</strong> file and places the new setting in
their too.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: #966633; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;?xml <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">version</span>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1.0"</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">encoding</span>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"utf-8"</span> ?&gt;
&lt;configuration&gt; &lt;configSections&gt; &lt;sectionGroup <font color="#ff0000">name</font>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"applicationSettings"</span><br /><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">type</span>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"System.Configuration.ApplicationSettingsGroup,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"</span> &gt;
&lt;section <font color="#ff0000">name</font>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Playground.ConfigurationOverride.DataAccess.Properties.Settings"</span><br /><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">type</span>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"System.Configuration.ClientSettingsSection,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"</span><br /><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">requirePermission</span>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"false"</span> /&gt;
&lt;/sectionGroup&gt; &lt;/configSections&gt; &lt;applicationSettings&gt; &lt;Playground.ConfigurationOverride.DataAccess.Properties.Settings&gt;
&lt;setting <font color="#ff0000">name</font>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"MySetting"</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">serializeAs</span>=<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"String"</span>&gt;
&lt;value&gt;Setting in DataAccess&lt;/value&gt; &lt;/setting&gt; &lt;/Playground.ConfigurationOverride.DataAccess.Properties.Settings&gt;
&lt;/applicationSettings&gt; &lt;/configuration&gt;</span>
        </pre>
        <p>
Next we will add a simple class to the DataAccess project with a single static method
that will return the value of the setting we have just created.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">namespace</span> Playground.ConfigurationOverride.DataAccess
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> SettingsHelper
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> GetMySetting()
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> Properties.Settings.Default.MySetting;
} } }</span>
        </pre>
        <p>
Next we will create anothe simple class, <strong>SettingsGetter</strong>, in
the but in the <strong>BusinessEntity</strong> layer this time. It will just return
the value returned from the <strong>SettingsHelper</strong> class in the <strong>DataAccess</strong> layer.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">namespace</span> Playground.ConfigurationOverride.BusinessEntity
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> SettingsGetter
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> GetDataAccessSettingValue()
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> DataAccess.SettingsHelper.GetMySetting();
} } }</span>
        </pre>
Next we need to create a presentation layer. So first off we will create a small web
application and add it to the solution, and grab a reference to the <strong>BusinessEntity</strong> layer.
Set the web site as the startup project. We will also add a <strong>Label</strong> to
the default webform and a <strong>Button</strong>. In the <strong>Page_Load</strong> handler
method populate the label text from the business entity method.<pre><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">protected</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Page_Load(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e) { uxSettingsLabel.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Playground.ConfigurationOverride.BusinessEntity.SettingsGetter.GetDataAccessSettingValue();
}</span></pre><p>
...and run the application, and allow the <strong>Web.Config</strong> file to be created.
The value of the setting in the <strong>DataAccess</strong><strong>App.Config</strong> file
should be displayed.
</p><p>
 
</p><p><font size="1">More to follow soon...</font></p><img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=f40ec3ec-6713-43ec-8007-f3b4ade7b1d8" /></body>
      <title>Override App.Config in the DataAccess layer with Web.Config or App.Config in the presentation layer.</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,f40ec3ec-6713-43ec-8007-f3b4ade7b1d8.aspx</guid>
      <link>http://www.duanewingett.info/2008/04/12/OverrideAppConfigInTheDataAccessLayerWithWebConfigOrAppConfigInThePresentationLayer.aspx</link>
      <pubDate>Sat, 12 Apr 2008 19:03:24 GMT</pubDate>
      <description>&lt;p&gt;
I'm sure many of you are aware that you can override the connection string settings
in your &lt;strong&gt;DataAccess&lt;/strong&gt; layer of your web application with connection
string settings in your &lt;strong&gt;Web.Config&lt;/strong&gt;. We found this out recently and
found it very useful in an intranet application at work recently. However this week
one of the other developers required that he could override a setting the &lt;strong&gt;BusinessEntity&lt;/strong&gt; layer
of his application from the &lt;strong&gt;App.Config&lt;/strong&gt; in the console layer.
&lt;/p&gt;
&lt;p&gt;
A quick chat with Mr Google didn't turn up a solution for this, so with this in mind
all three of us quickly tried to return a working solution. I'm going to try to give
an example of what we did, incase it something others may find of use. First we create
a solution with two class library projects within it. The first will&amp;nbsp;simulate&amp;nbsp;the &lt;strong&gt;DataAccess&lt;/strong&gt; layer
and the second will simulate the &lt;strong&gt;BusinessEntity&lt;/strong&gt; layer in an application.
In the &lt;strong&gt;BusinessEntity&lt;/strong&gt; project we will create a reference to the &lt;strong&gt;DataAccess&lt;/strong&gt; project.
&lt;/p&gt;
&lt;p&gt;
Starting with the &lt;strong&gt;DataAccess&lt;/strong&gt; project we will add an &lt;strong&gt;App.Config&lt;/strong&gt; file
by&amp;nbsp;creating a setting called "MySetting"&amp;nbsp;in the &lt;strong&gt;Settings&lt;/strong&gt; tab
of the project &lt;strong&gt;Properties&lt;/strong&gt;. The setting&amp;nbsp;scope will be set to
Application.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.duanewingett.info/content/binary/ConfigurationOverride_Settings.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
This creates a new &lt;strong&gt;sectionGroup&lt;/strong&gt; called &lt;strong&gt;applicationSettings&lt;/strong&gt; and
a new section in the &lt;strong&gt;App.Config&lt;/strong&gt; file and places the new setting in
their too.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: #966633; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;?xml &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;version&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1.0"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;encoding&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"utf-8"&lt;/span&gt; ?&amp;gt;
&amp;lt;configuration&amp;gt; &amp;lt;configSections&amp;gt; &amp;lt;sectionGroup &lt;font color=#ff0000&gt;name&lt;/font&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"applicationSettings"&lt;/span&gt; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;type&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"System.Configuration.ApplicationSettingsGroup,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/span&gt; &amp;gt;
&amp;lt;section &lt;font color=#ff0000&gt;name&lt;/font&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Playground.ConfigurationOverride.DataAccess.Properties.Settings"&lt;/span&gt; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;type&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"System.Configuration.ClientSettingsSection,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&lt;/span&gt; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;requirePermission&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"false"&lt;/span&gt; /&amp;gt;
&amp;lt;/sectionGroup&amp;gt; &amp;lt;/configSections&amp;gt; &amp;lt;applicationSettings&amp;gt; &amp;lt;Playground.ConfigurationOverride.DataAccess.Properties.Settings&amp;gt;
&amp;lt;setting &lt;font color=#ff0000&gt;name&lt;/font&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"MySetting"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;serializeAs&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"String"&lt;/span&gt;&amp;gt;
&amp;lt;value&amp;gt;Setting in DataAccess&amp;lt;/value&amp;gt; &amp;lt;/setting&amp;gt; &amp;lt;/Playground.ConfigurationOverride.DataAccess.Properties.Settings&amp;gt;
&amp;lt;/applicationSettings&amp;gt; &amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Next we will add a simple class to the DataAccess project with a single static method
that will return the value of the setting we have just created.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; Playground.ConfigurationOverride.DataAccess
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; SettingsHelper
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; GetMySetting()
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; Properties.Settings.Default.MySetting;
} } }&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Next we will create anothe simple class, &lt;strong&gt;SettingsGetter&lt;/strong&gt;,&amp;nbsp;in
the but in the &lt;strong&gt;BusinessEntity&lt;/strong&gt; layer this time. It will just return
the value returned from the &lt;strong&gt;SettingsHelper&lt;/strong&gt; class in the &lt;strong&gt;DataAccess&lt;/strong&gt; layer.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; Playground.ConfigurationOverride.BusinessEntity
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; SettingsGetter
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; GetDataAccessSettingValue()
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; DataAccess.SettingsHelper.GetMySetting();
} } }&lt;/span&gt;&lt;/pre&gt;
Next we need to create a presentation layer. So first off we will create a small web
application and add it to the solution, and grab a reference to the &lt;strong&gt;BusinessEntity&lt;/strong&gt; layer.
Set the web site as the startup project. We will also add a &lt;strong&gt;Label&lt;/strong&gt; to
the default webform and a &lt;strong&gt;Button&lt;/strong&gt;. In the &lt;strong&gt;Page_Load&lt;/strong&gt; handler
method populate the label text from the business entity method.&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;protected&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Page_Load(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e) { uxSettingsLabel.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Playground.ConfigurationOverride.BusinessEntity.SettingsGetter.GetDataAccessSettingValue();
}&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
...and run the application, and allow the &lt;strong&gt;Web.Config&lt;/strong&gt; file to be created.
The value of the setting in the &lt;strong&gt;DataAccess&lt;/strong&gt; &lt;strong&gt;App.Config&lt;/strong&gt; file
should be displayed.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;More to follow soon...&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=f40ec3ec-6713-43ec-8007-f3b4ade7b1d8" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,f40ec3ec-6713-43ec-8007-f3b4ade7b1d8.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>C#</category>
      <category>Config Files</category>
      <category>XML</category>
    </item>
    <item>
      <trackback:ping>http://www.duanewingett.info/Trackback.aspx?guid=728e6c3c-172c-4292-9d99-3e53560fb6d8</trackback:ping>
      <pingback:server>http://www.duanewingett.info/pingback.aspx</pingback:server>
      <pingback:target>http://www.duanewingett.info/PermaLink,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</pingback:target>
      <dc:creator>Duane Wingett</dc:creator>
      <wfw:comment>http://www.duanewingett.info/CommentView,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</wfw:comment>
      <wfw:commentRss>http://www.duanewingett.info/SyndicationService.asmx/GetEntryCommentsRss?guid=728e6c3c-172c-4292-9d99-3e53560fb6d8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As part of the preliminary research and design process for a prospective
new project at work one of the requirements will be for the application to provide
a webservice that can be consumed from a third party's Java application.
</p>
        <p>
So without further ado a quick .Net webservice was nocked up in C# with a single WebMethod.
The WebMethod would return a formatted string containing within it the value
passed in as a string parameter. The Webservice was deployed to localhost and tested
using the simple webform test that is present on a local instal.
</p>
        <p>
All good so far.
</p>
        <p>
Next is to build a small Java web project that can consume the webservice. So having
never written a Java application before, it's a quick trip to see Mr Google for a
working example of how to call a webservice from Java. ( <a href="http://www.duanewingett.info/2008/03/31/MyFirstJavaApp.aspx">See
My First Java App</a> ) Google thankfully turned up <a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=257552">David
Hobbs</a>' example "<span class="ArticleTopTitle" id="ctl00_ArticleTopHeader_ArticleTitle"><a href="http://www.codeproject.com/KB/XML/WSfromJava.aspx">How
to consume an ASP.NET webservice from Java via SOAP</a>"</span> on CodeProject. After
a an hour or after nocking up a quick Java webpage with an embedded applet
that will call the webservice and display the result, it should be a case of running
it and seeing it work like clockwork.... After all the whole idea of a webservice
is to platform unspecific, isn't it?....
</p>
        <p>
Well, I shouldn't really have expected miracles, should I? After a whole afternoon
of checking and double checking that the code was correct and using a free trial of <a href="http://www.prestosoft.com/edp_examdiffpro.asp">ExamDiff
Pro</a> to ensure that XML that the java code was out putting was exactly what
the XML that the server was expecting to receive I came to the conclusion that it
must be something perculiar to our network. The XML output was identical except for
the physical value of the parameter.
</p>
        <p>
So at the end of the day I was at a loss. I'm not sure if it is an error in the code,
or if the webservice expects different XML than what the description page offers up.
Or if there is a network security issue which isn't allowing communication between
the two applications. One of my .Net Windows applications calls a .Net webservice
which is built in the same way as this test one perfectly, and has done for the last
year! Event the third party representative was at a bit of a loss.
</p>
        <p>
So I am at a bit of a loss with this one. May be a fresh look in a new week will shed
some light. Who knows? If any one else has come accross this issue, and resolved or
not resolved it, please post and let me know your findings!
</p>
        <p>
          <hr />
        </p>
        <p>
        </p>
        <p>
          <font size="1">
            <strong>Postscript: #1</strong>
            <br />
          </font>I have just noticed on the botttom of David's CodeProject artical the following:
</p>
        <p>
          <em>
            <font color="#808080">
              <strong>Notes</strong>
              <br />
Some Java Virtual Machines (like the Microsoft one) only allow you to make a socket
connection to the same machine that hosts the Java class files. Therefore, if you're
using an applet like me, you will need to host the Java class files on the same machine
where the webservice resides.</font>
          </em>
        </p>
        <p>
I wonder if this has anything to do with the problem... Oh well, maybe tomorrow I'll
waste another fruitless afternoon trying to find out!! ;-)
</p>
        <p>
          <font size="1">
            <strong>Postscript: #2</strong>
          </font>
          <br />
Well after further investigation I haven't managed to determin the fault, but today
we tried a different approach and used the "Web Service proxy" object from the <strong>Business
Tier</strong> &gt; <strong>Web Services</strong> category in the New Gallery.
</p>
        <p>
          <img src="http://www.duanewingett.info/content/binary/NewGalleryWebService.jpg" border="0" />
        </p>
        <p>
We then followed the wizard and let it generate the code. The outputted code was tested
and hey presto!!
</p>
        <p>
So I guess this topic is closed for me now!
</p>
        <img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=728e6c3c-172c-4292-9d99-3e53560fb6d8" />
      </body>
      <title>"Invalid Parameter" error when attempting to consume a .Net WebService from a Java application over network.</title>
      <guid isPermaLink="false">http://www.duanewingett.info/PermaLink,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</guid>
      <link>http://www.duanewingett.info/2008/03/31/InvalidParameterErrorWhenAttemptingToConsumeANetWebServiceFromAJavaApplicationOverNetwork.aspx</link>
      <pubDate>Mon, 31 Mar 2008 14:07:10 GMT</pubDate>
      <description>&lt;p&gt;
As part of the&amp;nbsp;preliminary research&amp;nbsp;and design process for a prospective
new project at work one of the requirements will be for the application to provide
a webservice that can be consumed from a third party's&amp;nbsp;Java application.
&lt;/p&gt;
&lt;p&gt;
So without further ado a quick .Net webservice was nocked up in C# with a single WebMethod.
The WebMethod would return a&amp;nbsp;formatted string&amp;nbsp;containing within it the value
passed in as a string parameter. The Webservice was deployed to localhost and tested
using the simple webform test that is present on a local instal.
&lt;/p&gt;
&lt;p&gt;
All good so far.
&lt;/p&gt;
&lt;p&gt;
Next is to build a small Java web project that can consume the webservice. So having
never written a Java application before, it's a quick trip to see Mr Google for a
working example of how to call a webservice from Java. ( &lt;a href="http://www.duanewingett.info/2008/03/31/MyFirstJavaApp.aspx"&gt;See
My First Java App&lt;/a&gt; ) Google thankfully turned up &lt;a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=257552"&gt;David
Hobbs&lt;/a&gt;' example "&lt;span class=ArticleTopTitle id=ctl00_ArticleTopHeader_ArticleTitle&gt;&lt;a href="http://www.codeproject.com/KB/XML/WSfromJava.aspx"&gt;How
to consume an ASP.NET webservice from Java via SOAP&lt;/a&gt;"&lt;/span&gt; on CodeProject. After
a&amp;nbsp;an hour or after nocking up a quick Java webpage&amp;nbsp;with an embedded applet
that will call the webservice and display the result, it should be a case of running
it and seeing it work like clockwork....&amp;nbsp;After all the whole idea of a webservice
is to platform unspecific, isn't it?....
&lt;/p&gt;
&lt;p&gt;
Well, I shouldn't really have expected miracles, should I? After a whole afternoon
of checking and double checking that the code was correct and using a free trial of &lt;a href="http://www.prestosoft.com/edp_examdiffpro.asp"&gt;ExamDiff
Pro&lt;/a&gt; to ensure that XML that&amp;nbsp;the java code was out putting was exactly what
the XML that the server was expecting to receive I came to the conclusion that it
must be something perculiar to our network. The XML output was identical except for
the physical value of the parameter.
&lt;/p&gt;
&lt;p&gt;
So at the end of the day I was at a loss. I'm not sure if it is an error in the code,
or if the webservice expects different XML than what the description page offers up.
Or if there is a network security issue which isn't allowing communication between
the two applications. One of my .Net Windows applications calls a .Net webservice
which is built in the same way as this test one perfectly, and has done for the last
year! Event the third party representative was at a bit of a loss.
&lt;/p&gt;
&lt;p&gt;
So I am at a bit of a loss with this one. May be a fresh look in a new week will shed
some light. Who knows? If any one else has come accross this issue, and resolved or
not resolved it, please post and let me know your findings!
&lt;/p&gt;
&lt;p&gt;
&lt;hr&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;strong&gt;Postscript: #1&lt;/strong&gt;
&lt;br&gt;
&lt;/font&gt;I have just noticed on the botttom of David's CodeProject artical the following:
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&lt;font color=#808080&gt;&lt;strong&gt;Notes&lt;/strong&gt;
&lt;br&gt;
Some Java Virtual Machines (like the Microsoft one) only allow you to make a socket
connection to the same machine that hosts the Java class files. Therefore, if you're
using an applet like me, you will need to host the Java class files on the same machine
where the webservice resides.&lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
I wonder if this has anything to do with the problem... Oh well, maybe tomorrow I'll
waste another fruitless afternoon trying to find out!! ;-)
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;strong&gt;Postscript: #2&lt;/strong&gt;&lt;/font&gt;
&lt;br&gt;
Well after further investigation I haven't managed to determin the fault, but today
we tried a different approach and used the "Web Service proxy" object from the &lt;strong&gt;Business
Tier&lt;/strong&gt; &amp;gt; &lt;strong&gt;Web Services&lt;/strong&gt; category&amp;nbsp;in the New Gallery.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.duanewingett.info/content/binary/NewGalleryWebService.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
We then followed the wizard and let it generate the code. The outputted code was tested
and hey presto!!
&lt;/p&gt;
&lt;p&gt;
So I guess this topic is closed for me now!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.duanewingett.info/aggbug.ashx?id=728e6c3c-172c-4292-9d99-3e53560fb6d8" /&gt;</description>
      <comments>http://www.duanewingett.info/CommentView,guid,728e6c3c-172c-4292-9d99-3e53560fb6d8.aspx</comments>
      <category>.Net</category>
      <category>Java</category>
      <category>SOAP</category>
      <category>Web Services</category>
      <category>XML</category>
      <category>JDeveloper</category>
    </item>
  </channel>
</rss>