QAT Insights

Highlighting recent QAT solution releases, insights, service and industry information, upcoming events, case studies, and press releases.

The Spring.NET Web Service Exporter Part 4 - Spring Configuration

July1

This is the last part of the Spring.NET Web Service Exporter example. I’ve shown the Web.config entries and the application details. Now we are only missing the Spring configuration file - named Spring.xml in my example. This is the whole configuration file (note that I have not set up transaction handling or other aspects in this example):

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">

Here the DAL is configured. Note that the dictionary is completely populated in the configuration. No coding necessary!

<!-- DAL-->
  <object id="LookUpDalRef" type="Qat.Demo.LookUpDal, QATDemo">
    <property name="Data">
      <dictionary key-type="string" value-type="Qat.Demo.LookUpDTO, QATDemo">
        <entry key="USA">
          <object type="Qat.Demo.LookUpDTO, QATDemo">
            <property name="Key" value="USA"/>
            <property name="Title" value="United States of America"/>
            <property name="Description"
              value="USA is the abbreviation for United States of America."/>
          </object>
        </entry>
        <entry key="UK">
          <object type="Qat.Demo.LookUpDTO, QATDemo">
            <property name="Key" value="UK"/>
            <property name="Title"
              value="United Kingdom of Great Britain and Northern Ireland"/>
            <property name="Description"
              value="UK is the abbreviation for United Kingdom of
              Great Britain and Northern Ireland."/>
          </object>
        </entry>
      </dictionary>
    </property>
  </object>

Configuring the service. Note the reference to the DAL object. You will not have to look up or instantiate anything in the code.

<!-- Services -->
<object id="LookUpService" type="Qat.Demo.LookUpService, QATDemo">
<property name="LookUpDal" ref="LookUpDalRef" />
</object>

And now the Web Service Exporter. You need to declare one exporter per web service. The name attribute sets the url:

  <!-- Web Service Exporters -->
  <object id="TestServiceExporter" name="/TestService.asmx"
      type="Spring.Web.Services.WebServiceExporter, Spring.Web">
    <property name="TargetName" value="LookUpService"/>
    <property name="Namespace" value="http://QAT/services"/>
    <property name="Description"
        value="Test Web Service.
          Demonstrates Spring.NET Web Service Exporter."/>

The typeAttributes allow using our custom DTO (in some
situations, you may also have to expose the [] Array type although in
this example it is able to construct the array type automatically).

      <property name="TypeAttributes">
        <list>
          <expression
            value="@[XmlInclude(T(Qat.Demo.LookUpDTO, QATDemo))]"/>
        </list>
      </property>

Exposing the web service methods. * can also be used as a wild card key. Note that only the most specific match will be applied to your method. If you enable session access in the * entry but have a separate entry for your method, the session access will not automatically be applied.

      <property name="MemberAttributes">
        <dictionary>
          <entry key="LookUp">
            <list>
              <object type="System.Web.Services.WebMethodAttribute,
                 System.Web.Services">
                <property name="Description" value="Looks up an
                  abbreviation."/>
              </object>
            </list>
          </entry>
          <entry key="LookUpAll">
            <list>
              <object type="System.Web.Services.WebMethodAttribute,
                   System.Web.Services">
                <property name="Description"
                    value="Returns array of all known abbreviations."/>
              </object>
            </list>
          </entry>

This method has session access enabled.

          <entry key="AccessSession">
            <list>
              <object type="System.Web.Services.WebMethodAttribute,
                  System.Web.Services">
                <property name="EnableSession" value="true"/>
              </object>
              <object type="System.Web.Services.WebMethodAttribute,
                  System.Web.Services">
                <property name="Description"
                  value="Accesses the User Session."/>
              </object>
            </list>
          </entry>
        </dictionary>
      </property>
    </object>
</objects>

Now our web service is ready. It will be exposed at <application context>/TestService.asmx. You also can use the LookUpService object directly either within the Spring configuration through

<property name="..." ref="LookUpService"/>

or programmatically:

Spring.Context.IApplicationContext ctx =
   Spring.Context.Support.ContextRegistry.GetContext();
ILookUpService lookupService = ctx["LookUpService"] as ILookUpService;

That wasn’t too hard, was it? Once you actually take a closer look at Spring configuration, it is actually quite intuitive. You still may say that it would have been quicker to code the traditional way. With the simple example I’ve shown, you would be correct. But consider a large, enterprise-level application: Need to expose the service as a COM+ component as well? It’s now a matter of configuration (for more details, see the Spring.NET documentation). In a large application, separating implementation from configuration and reducing the amount of hand-written code to the essential business logic will greatly enhance the maintainability and flexibility and make the initial overhead worthwhile.

Anke

posted under .NET | No Comments »

Domain Name Scam Alert

June26

Recently a client asked me to look into a suspicious correspondence received concerning their website. In this particular case, my client received a fax from a company called “US Domain Protection” at 130 Church St Suite 280, NY, NY 10007 www.USDomainProtection.com that says they had until 06/25/09 to reply or they could loose rights to their domain.. The fax was full of legal-speak, with threatening phrases like “protecting a domain registrant” and warnings like “you are required to advise the domain notification processor of your intent to (a) secure this domain name or (b) release your first right to use preference”. This all sounds very official and in need of immediate action. I was immediately suspicious since this “Final Notice” came by fax.

First, I looked up the domain registry information for our client and found that it was registered until 2010 with a reputable company to make sure that the domain was in no real danger. (You can check your domain name expiration date yourself: Go to: http://whois.domaintools.com/ and enter your domain name. If someone tells you your domain name is going to expire, don’t take their word for it, verify this yourself with this free, easy tool.) Satisfied that the domain was safe, I looked up the company the fax was from to find out what kind of scam they are running. US Domain Protection has a website that was all about protecting domain registrations and looks all legal and official and includes links to legitimate resources to further confuse people. I ran a search on their domain registration ( http://whois.domaintools.com/usdomainprotection.com) and found that they are part of a group of about 465 other domains . The domain has also been moved around on 7 unique name servers over 8 months which is particularly suspicious and leads me to believe that they have been kicked off a number of hosting accounts due to complaints. Also, this domain was created on November 05, 2008 and expires on November 05, 2009. I also checked out the phone number 1-800-690-1269 online and found that a number of people have had similar and bad experiences with the company. In fact, one person reported receiving the fax, and when unable to reach the person who manages their domain name, returned the call and was told they needed to pay the $35 by credit card to keep it. They were charged $350 instead of $35 and later found out that the domain name doesn’t actually expire until 2010. This was a scam, but the credit card company wouldn’t take the charge off and they were told them to call the company back and cancel the transaction. Since the company wouldn’t answer the phone, they couldn’t cancel the transaction and learned an expensive lesson.

Copy of scam fax from US Domain Protection

Copy of scam fax from US Domain Protection

So if you get one of these notices, rest assured it has nothing to do with the domain name you currently own. Call it trash, phishing scam, or simply fraud. If you receive an email or fax like this, fill out a FTC complaint HERE.

« Older Entries