cs tab

cs tab

  • NA
  • 1
  • 0

3 Tier, WCF

Sep 30 2009 3:40 AM

hi,

First of all, i need to say thank you.
i successful to create my 3 tier with WCF method.
but i still got somethings that i cant get it and dont understand.
my project i divided into 5 layers.

myWCF(host),
myClient(GUI/exe),
myClientBz(Business Logic),
myDAL(Data Access Layer),
myClientInterfaces(interface)

It contain error if try to call more than 1 host. (host name redundant used)
my Business Logic not just 1 class.
and i intending to make myDAL(data access layer) for my interface layer.
but i don't know weather it is suitable to do that or not.(maybe no need, becourse DAL and BLL
going to in place at Application Server)
but my business logic is sure will more than 1 class.


myWCF config file.
**cspc is my pc name(ip address)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metadataBehavior">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
   
    <services>
     
      <service behaviorConfiguration="metadataBehavior" name="myClientBz.myMessager">
        <endpoint address="myMessagerService" binding="basicHttpBinding" bindingConfiguration="" name="basicHttp" contract="myClientInterfaces.imyMessager" />
        <endpoint binding="mexHttpBinding" bindingConfiguration="" name="metadataExchange" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://cspc/myMessager" />
          </baseAddresses>
        </host>
      </service>
    
    </services>
  </system.serviceModel>
</configuration>

myClient config file (i created by running the host exe, sametime add service references at myClient's reference)
here is how it is look like:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="basicHttp" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
          
          <endpoint address="http://cspc/myMessager/myMessagerService"
              binding="basicHttpBinding" bindingConfiguration="basicHttp"
              contract="myMessagerService.imyMessager" name="basicHttp" />

        </client>
    </system.serviceModel>
</configuration>

in order to run my host i write:

using (ServiceHost host = new ServiceHost(typeof(myMessager)))
{
   host.Open();
   Console.WriteLine("Service is up and running.");
   Console.WriteLine("Press <Enter> to stop service...");
   Console.ReadLine();
   host.Close();
}

to test my exe are ok, i write in myClient form 1

myMessagerService.imyMessager proxy = new myClient.myMessagerService.imyMessagerClient();
string result = proxy.SendMessage();
MessageBox.Show(result, "xx");

it work FINE. it return me a message that i write in myClientBz
wirten below:

using System;
using System.Collections.Generic;
using System.Text;
using myClientInterfaces;

namespace myClientBz
{
  public class myMessager : imyMessager
  {
    public string SendMessage()
    {
      return "Try Me~";
    }
  }
}


If myClientBz required extra class, what needed in next?
Required to add myCaculation, myInformation into myClientBz.
Same i need to add interface for myCaculation, myInformation into myClientInterfaces right?
My project going to Touch on SQL DataBase.
which mean i required to add interface and config file(myDAL) again?
or is depend on how to write communicate way my with my SQL DB?

Please give advise or sample.


Answers (1)