Asp.Net: invoke WCF method with WCF Test Client

by Pieter Brinkman 20. August 2009 02:53

When deploying a Silverlight application we ran into problems a WCF web-service, to find out what the problem was I wanted to invoke the method.

Microsoft shipped an application for invoking methods from your Windows PC (WCFtestclient.exe). The following steps explain how to use WCFtestclient.exe.

First startup Visual Studio 2008 Command Prompt. In the command prompt type wcftestclient, the application will startup.

Now we need to add the Service. Click File and Add Service.

 Add Service to wcftestclient


Add the URL to your service in the pop-up and pres ok. The service will now add all methods from your service. You can add multiple service URLs.

Double click the method you want to invoke from the tree on the left pane. Enter the values that are required for the Invoke and press Invoke. The method will be invoked.

Invoke WCF method


The right bottom pane will show the response. In my case this shows the Stack-trace because of the error. Normally this will show the web-service response (XML).

With the stack-trace I could located the error and fix it.

Hope this helps,

Pieter

 

Tags: , ,

ASP.Net | Microsoft | Silverlight | Visual Studio

Asp.Net: Charting Control (Error ChartImg.axd)

by Pieter Brinkman 3. March 2009 02:49

After installing and playing with the Asp.Net Charting control I decided to use it for a customer. When integrating the control to the project I got the following error

"Error executing child request for ChartImg.axd"

This error occurred because I did not update my web.config file. You have to add the following appSettingkey, httpHandler and handler.

<appSettings>
    <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFilesDit\;" />
</appSettings>
<httpHandlers>
    <add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>


<handlers>
    <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>

More info about the Charting control:
http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx

Enjoy charting,
Pieter

Tags: , , ,

ASP.Net | Controls | Microsoft

.Net: Example basic consoleapplication with parameters

by Pieter Brinkman 20. February 2009 08:01

This is a basic example of an console-application with parameters used for a scheduled tasks.

The application will be scheduled to run every day with the -n parameter. But the application can also run on a specific date by using the -d parameter.

class Program
{
 //Parameters
 private static DateTime theDate;
 private static RunMode mode = RunMode.NotSpecified;

 static void Main(string[] args)
 {
  if (CollectParameters(args))
  {
   Console.WriteLine("Beginning appliation in mode \"{0}\" with date {1}.", mode, theDate);
   Logger.LogEvent("Starting StatisticConsoleApp", args, (int)Logger.LogType.Message);

  }
 }

 private static bool CollectParameters(string[] args)
 {
  if (args.Length > 0)
  {
   for (int ii = 0; ii < args.Length && mode == RunMode.NotSpecified; ii++)
   {
    //Default commands for support -h and /?
    if (args[ii].ToLower().Trim() == "-h" || args[ii].Trim() == "/?")
    {
     PrintHelpText();
     return (false);
    }
    else
    {
     //Get clear input params
     string inputParam = args[ii].ToLower().Trim();
     inputParam = Regex.Replace(inputParam, "[/-]", "");

     switch (inputParam)
                    {
                        case "n":
                            mode = RunMode.Normal;
                            theDate = DateTime.Now;
                            break;

                        case "d":
                            mode = RunMode.SpecificDate;
                            if ((ii + 1) < args.Length)
                            {
                                theDate = Convert.ToDateTime(args[ii + 1]);
                            }
                            break;
       default:
        if(args[ii].Substring(0,1) == "-")
         Console.WriteLine("Unknown switch {0}. Ignoring this switch.", args[ii]);
        break;
      }
    }
   }

   if (mode != RunMode.NotSpecified)
   {
    return true;
   }
   else
   {
    Console.WriteLine("No valid parameter specified. Aborting processing.....");
    return false;
   }
  }
  else
  {
   PrintHelpText();
   return false;
  }
 }


 private static void PrintHelpText()
 {
  Console.WriteLine("\nUsage: Statisticprocess application");
  Console.WriteLine("");
  Console.WriteLine("  -n");
  Console.WriteLine("    The application will run in normal mode.");
  Console.WriteLine("    The statistics will be processed with the current date.");
  Console.WriteLine("  -d");
  Console.WriteLine("    The application runs in 'specific date' mode.");
  Console.WriteLine("    The statistics will be processed with the input date");
  Console.WriteLine("    The date may be specified in any format as long as it can be ");
  Console.WriteLine("    translated unambiguously into a proper date.");
  Console.WriteLine("");
  Console.WriteLine("");
  Console.WriteLine("    Note: Only one mode can be specified.");
  Console.WriteLine("          If two modes are specified, the second mode is ignored.");
  Console.WriteLine("");
  Console.WriteLine("    Example: In this example application runs in \"specific date\" mode ");
  Console.WriteLine("             for the date \"10-sep-2006\".");
  Console.WriteLine("");
  Console.WriteLine("    TOOLNAME [-d 1-jan-2009]");
  Console.WriteLine("");
 }
}

[/code]



If you copy this class into your program.cs you will get some errors concerning my own loghandler and the missing RunMode enum. To fix this delete the code lines for the logging and add the following enum to your console application.

public enum RunMode : byte
 {
  NotSpecified,
  Normal,
  SpecificDate
 }


This is not the clearest example but if you have any questions don't hesitate to ask.  

Tags: ,

Microsoft

Running WCF on IIS 5 (Windows XP)

by Pieter Brinkman 2. February 2009 09:53

After running WCF on my Vista laptop (IIS7) I needed to deploy the application on some Windows XP computers. Again some strange errors occurred:

[code:html]

Error Description: "This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.
Parameter name: item"

[/code]


The problem is that WCF cannot handle more than one identity (host headers) per website. At first I configured IIS to have one HostHeader. That solution was just to dirty. So I kept on searching the internet.


You can fix this problem by adding prefix-key(s) in the baseAddressPrefixFilters section of the Web.Config:

[code:xml]
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
        <add prefix=”http://www.local.develop/>


</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>
[/code]


Hope this helps.


Sources:
http://geekswithblogs.net/robz/archive/2007/10/02/WCF-in-IIS-with-Websites-that-have-Multiple-Identities.aspx
http://blogs.msdn.com/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx

Tags: , , ,

iis | Microsoft

Microsoft Tag: Snap my vCard

by Pieter Brinkman 8. January 2009 02:46

When surfing the internet I start reading about Microsoft Tag Beta (of course). With Microsoft Tag you can create links with a image-pattern. The image-pattern can be decoded to a link with the Microsoft Tag program on your Windows Mobile (with camera).

You can create graphical image-patterns with the following actions:

  • Link to an URL
  • Free text
  • vCard
  • Dialer

It looks very promising. Not every tag on a screen gets recognized at once, but the printed tags work very well.

I've placed my vCard in a tag on my blog. Just try to tag it ;-)

Tags: , , ,

Microsoft

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Me

My name is Pieter Brinkman I am a .NET Software Engineer for Achmea IT in De Meern, The Netherlands. My interests are mainly web applications created with ASP.NET, MSSQL and Silverlight.

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

RecentComments

Comment RSS

Most comments

club penguin cheats club penguin cheats
4 comments
us United States
Web Design Company Web Design Company
2 comments
Web design Web design
2 comments
gb United Kingdom