Divis Blog

Just another geeks blog.

REST in REST is not a good idea

clock January 23, 2009 16:58 by author Divi

Hi all,

Today I spent some time wrinting a wrapper for an old REST service to make it read its data from a newer service. Unfortunately it seemed to be a little more complicated than I thought. As I just thought I’d have finished my work, I got the following error message:

(The remote server has responded with an unexpected answer: Method Not Allowed.)


Oops? A protocol error? What have I done? That nettled me that much that I decided to fix it instead of hurry myself and write a workaround for it. At first I thought it could be a configuration fault … but that it wasn’t … after I built a test-solution in VisualStudio for this structure, I could confirm my suspicion. The above named “method” in the error message has been the kind of transmission between the services. My REST-service expected a GET-request, but strangely my client sent a the request via POST:

Because of this I checked the definition of my contracts, if my fault could be there, but everything seemed to be right. Originally I used the WebGet attribute, but also the WebInvoke with “Method”=”GET” made no difference.

After I sat there for some time and couldn’t believe that it should be an error of WCF itself, I put a web-form for, testing reasons, in the same directory as my *.svc file and copied the service request in there … it worked:

So let’s note down – if I call a REST-service by another REST-service with a REST-client, I get as method alwas „POST“ … if I copy exactly the same code and configuration into a web-form and invoke it there, I get a „GET“-request (if I want to) … for the moment that seems to be a problem I can’t fix myself.

But even if you can’t get it to work THAT way, you could still use „POST“ instead of the „GET“ method. This will work in both places. The only negative thing is that you can’t call the service directly by opening the specific request in your browser. If you can’t use another method than “GET”, you could still use the HttpWebRequest directly for invoking the service.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Writing ICQ Open Xtraz

clock January 15, 2009 08:04 by author Divi

As I read that ICQ 6.5 has been release some days agon, I wasn’t quite excited ... various errors, crashes and disturbing little things had put the old versions into a bad light. Actually I had sworn to myself never to use ICQ again, after it crashed the last time without any reason, but because I already broke that intention several times by clicking quicklaunch-items that were laying around, I thought I could at least have a look at the new version ... The only thing worth to mention seemed to be the "Open Xtraz"-campaign:

clip_image002

I almost left the page as I decided to find out what these Open Xtraz would be. So I opened the Developers Zone and got desperately disappointed ... about 10 forum entries and only rudimentary instructions for the Xtraz just wasn’t what I expected. But at least there was a list of things to do when you wanted to develop your own extra:

1.) Download Open Xtraz Developer Tool

2.) Download Open Xtraz Template

3.) Develope and test

4.) Upload Xtra into the gallery

Seemed to be quite simple – so I downloaded the DevTool and clicked the link for getting the template – but the template didn’t want to be loaded as long as I wouldn’t have installed the new ICQ, so I decided to install it.

After everything was installed, I first opened the screen "My Xtraz" (See below). The screens had been empty at this point. So I clicked the "button" "Create Xtra" (at the right bottom).

clip_image004

But that didn’t open, as expected, the developer tool, but a link which pointed back to the "Developer Zone". Here I had to click on the link "Download template", which made ICQ create a directory on my drive. In this directory were placed two subfolders named "content" and "theme" as well as several configuration files. All together it remembered me on the packages which are used to create Firefox extensions. In another subfolder in the themes directory you can find the icons (ICQ not wants you to change their file names). And lastly there’re Javascript-, HTML and some image files in the "content"-folder.

If you open the Xtra it will look somehow like this:

clip_image006

And here we can see the reason why it’s necessary to download a new template for each Xtra. ICQ seems to create the IDs in this way (see the title of the page (green bar))… As if they couldn’t have done this while uploading the Xtra into the gallery ;-)

Well ... at least we now know that it’s just HTML and Javascript. So let’s have a look into the "developer tool" ... you guess it:

clip_image008

Nothing special - instead of some kind of developement environment or at least something that could give you a hint how to do it, it’s just a UI for setting some metadata for the project. For example you can set the name or the description of the project as well as the size of the window in which the Xtra should be displayed.

In the middle you’ll find two radio-buttons, which decide where the project is located ... The upper radio button (default) simply contains a link to the directory which ICQ created while creating the Xtra. The lower radio button (this could be quite interesting) tells the Xtra that the project is located at a specific web address. This means that you could for example host interactive content on your own server with a database behind it.

The locations below the radio buttons are more for your information then meaningful for any actions - they just help you getting through the jungle of icq template-directories ;-). Lastly at the very bottom there’s a link for creating a zip archive out of your Xtra which you then can upload - that’s all about the "developer tool".

So let’s have a look at the files in the directories themselves.

The HTML-file:

The HTML file has links to the included func.js file as well as a link to a Javascript file that is located at the ICQ-server, which contains the API. The rest of the files only contain some HTML and CSS, which result at the screenshot you could see above.

The JS-file:

In the JS file you got the following first line:

var icqConnector = XtrazConnector.getIcqConnector();

Here will be the XtrazConnector-object used to initialize the so called IcqConnector. If you got a debugger, just like the Visual Studio, you simply can insert the keyword "debugger" into the first line of the init method and you get any information about the Connector:

clip_image010

At my first peek at this interface, I really had to laugh quite loud – didn’t I just read that the JS file, which was hosted at the ICQ server itself, was named "open_xtraz_wrapper_1.js"?  So why did we get here already ApiVersion 2? ;-) ... well ... details ;-D.

At least we can see here a rough overview about the functions which the Xtraz API is offering. We can create "Alerts" (Alerts are the small windows which appear directly above the SysTray) and send a message there... The attempt to use it for debugging reasons turned out to be very very annoying, because I flooded myself with Alerts and had to click each single one to read the next one ;-).

Another method for example is GetUserList(). This method returns the following object:

clip_image012

At first I was a little bit over-challenged, because I thought I could access the properties via their indexes – but this was prohibited to me. Would I have had a look into the documentation a little bit earlier (which btw. doesn’t explain how it works), I could have saved me some time for searching, because at the definition of the method "GetGroupList()" they’re accessed via "Group(Idx)" which also works for this method ... So we can simply create a loop through all the users via a for loop which walks all the items from zero to the number of items:

var users = icqConnector.getUserList();
for (var i = 0; i < users.Count; i++)
{
  var user = users.Item(i);
}

 

The user object then offer you all the information about your contacts which these entered – that means in my case I always had the nick name at hand but only very rarely the real name. The birthday was filled at the half of all my contacts, so I decided to create a birthday list for testing. After some attempts it looked similar to this:

clip_image014

The scrollbar I had to add myself, but that was done very quickly, because the "Developer Tool" allowed me to set a fix height of the window and I just had to add a DIV with the specific height and the style property "overflow:auto". Of cause I added a small headline, as well as a link to my website – but that’s all. One interesting thing about this was the case that ICQ threw an Javascript-error as I tried to access a table via innerHTML – because of this the list is only mad of floating DIVs.

After everything was finished I tested if everything worked fine - and then you could instantly upload it ... I thought :-D ... As I tried to upload the project I got the error message that my mail address could not be verified ... ok - because of security reasons they should do something like this, to prevent malware from being uploaded ... But: After the confirmation of my mail address (ICQ itself removed the "not verified" message from the settings), I still got the message. So I searched via Google for a solution of my problem and found someone who wrote that it didn’t work for him as well until he created a new account. Because I already spent some time for writing this Xtra I decided to try this solution and created (unwillingly) a new account - but that also didn’t work - so I tried to restart my ICQ - and - I was able to upload a version...

Because I could neither find a hint if it worked in the "My Dev" section nor on icq.com, I posted a complaint, that something didn’t work over there...

Meanwhile I got a mail from ICQ ... In this they write, that my Xtra doesn’t match the requirements ... Reason: I didn’t create my own icon. ... damn - ok - icon created and tried again to upload ... obviously they respected my complaint, because now you can’t read anymore "Mail address not valid", but just:

clip_image016

"Upload failed" ... without any reason - without description - nothing that says why the upload failed - I think they just replaced the error message, so that noone can see how they are unable to conrol their own system...

Conclusion:

I think Open Xtraz are a really nice idea ... I think you could create almost something like a second Apple AppStore - but I also think they really fouled up while implementing it. I hit that often on my desk because of the frustration that made me headaches while I was kicked out, tried to login without success or upload files that were blocked without any help, that I’m quite unwilling to deal any further with it ... Request to ICQ: Fix that damn bugs - or at least don’t be that petty to refuse working uploads because they don’t have the icon you want. THANKS!

If someone is interested enough to engage with this and hasn’t been infected by my annoyance, you can find the reference to the API here. I wish you a lot of fun with your projects - it’s quite funny - I hope you will succeed with your uploads ;-)

[Update]

About 3-4 days after my second complaint I got a message from ICQ that told me that my error was recognized and fixed. Meanwhile the birthday list has been downloaded about 10.000 times. You can find its gallery page here. Now everything seems to be working fine. I'm glad to see that ICQ was able to fix their problems. One warning I'd like to give you for your way: If you're using alternative clients for the ICQ network, you might get multiple contact requests daily by bots that try to add you to their contact list. I got about 4-5 contact requests a day from several russian accounts. (And of course - I also tried to reply to them to check wheter it could be just someone interested in talking to me ;-D). If you're using ICQ itself, you can open your settings and block all messages from persons which are not in your contact list. That's working fine with ICQ. In Trillian this doesn't seem to work the way I wanted it to (as far as I experienced it).

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Twitter is a nice thing

clock October 12, 2008 00:25 by author Divi

I just was recovering the menu of my blog, because the links of my projects as well as the button for switching the language were not shown since the last update anymore. As I was just adding some stuff I realized that the BlogEngine has a widget for twitter.

What is twitter?

Twitter ist a page where you can leave short messages (almost like a SMS) to share with your friends what you're just doing. Others then can register themselves to stay up-to-date with your news. It's some kind of bulk-SMS with self-registration.

image

What I think about twitter?

I think twitter is a very nice idea, that could get big very fast. The only problem with twitter is that the people you want to share your thoughts with, need to be interested in you. That means - if noone watches your twitter-feed, noone will ever read it.

So if you got friends that are interested in reading what you're doing all day - twitter is a realy good tool to accomplish that - if not - you should know what twitter is, just to be able to discuss with someone, but you should save the time for writing the texts.

One nice thing about twitter is: You may set your messages to private-only. In this case everyone has to ask for your permission to subscribe to your feed.

Twitter-Widget

My intention was to write a short script to enable the BlogEngine to get my feeds. Twitter is very easy to handle, because it publishes a rss feed of every user which you can even limit by the specific parameter to save your and your servers traffic. But as I already told you earlier, BlogEngine already has a tool to do this for me, so I just had to insert my twitter-data (address and rss feed) so the tool could fetch them for me.

Twhirl

Because sometimes it's very annoying to login on twitter.com to post your last message, there're several tools which you can install on your PC that do the login, posting and even the retrieving of your friends feeds for you. One of these tools, that is unfortunately not listed in the downloads section of twitter.com is twhirl. Twhirl is a desktop client for twitter, based on Adobe Air. But even though this requires you to install Adobe Air, it's not a big deal, because the Air- as well as the twhirl-installation are almost self-running. As soon as you installed twhirl, you're getting the following list-view, which you can style by a well filled list of skins:

image

 

Summing up:

It's a quite nice idea for chatty people, but you have to have the nerves to always keep your messages up-to-date - and people that are willing to read what you're writing - otherwise twitter would be like an instant messenger without contacts ;-).

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Hide and seek with WPF

clock October 9, 2008 22:36 by author Divi

At the moment I'm using most of my time for learning WPF, because a while ago I got the crazy idea (I must have been drunk) that this could become my first MCTS certificate ;-). Since then I'm experiencing a continuos up and down everytime I open my Visual Studio. I mean - hey - wouldn't it be boring to always know what a method returns? I haven't casted as much as since I know WPF - and it's always a pleasure to think about what I could insert into a method, which expects only a completly unknown interface.

The first book I used for studying was, of course, the Microsoft "Training Kit". And exactly in that book I found a funny example that can demonstrate my feelings as good as nothing else.

The example explains how to write my own custom-button - I didn't keep the colors of the example I must confess - but all summed up I got something like this:

image

While I was enjoying the beautiful animation I was able to attach to the button (it got shrunk almost invisible and returned to its origin size), I recognized that there was something strange: The button got smaller and smaller ...

 image image

Obviously WPF replaces the origin size of the button, when it's clicked before the AutoReverse of the Animation finished. Ok - in some way this might be logical, because otherwise you wouldn't be able to handle an object that just is being animated. But I think this is one of the many small things that give WPF some kind of unfinished touch...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Blog version updated

clock September 21, 2008 22:41 by author Divi

After several days I couldnt get myself writing any interesting news, Ive now updated the version of the Blogengine from 1.3.x to 1.4.5. As you can see there re still some texts missing, but I ll get them fixed as soon as possible. The layout has changed, because it s one of the new versions defaults layouts. The old one worked though, but I wanted to try something new.

I hope to get myself here more often after that small update.

Have a nice evening.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


MS is not cool enough

clock August 25, 2008 15:54 by author Divi

Hi all,

How doesn't know it yet: "Photosynth" is a project of the "Microsoft Live Labs", where you can upload your pictures which Photosynth then tries to combine to a big one. If that works well enough, you're then able to click through the single parts of the big image to get a three-dimensional impression.

Some days ago I downloaded the required plugin, installed it and uploaded some pictures from a wedding party. Everything worked fine, but as I just wanted to show the result to my girlfriend, I got the following message:

"Unfortunately, we're not cool enough to run on your OS yet. We really wish we had a version of Photosynth that worked cross platform, but for now it only runs on Windows. Trust us, as soon as we have a Mac version ready, it will be up and available on our site."

image

Ok - beside the fact that I already installed and ran that plugin ... how the hell do they get the idea I could be a MAC user? Ok - if I'd be using Firefox or Opera - I could take this as a joke ... but I used a MS-IE7! I hope they'll fix it these days, because I really appreciated that cool 3D-view. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Much to do!

clock July 20, 2008 22:21 by author Divi

Since a while I had no time anymore to write some texts for my blog, but because there was just a little break, I thought I could add a short summary of my projects:

That thing that swallowed most of my time during the last weeks was the Microsoft exam 70-536: "Microsoft .NET Framework - Application Development Foundation". After I investigated all my free time in it and couldn't get it at the first try, I had to take my second shot. But the passing of the exam didn't release that much of my time, because all that projects that had been bottled-up had to be done now.

Here're some of them:

Pixelkaempferin - alias Jessika Wollstein

image

A good friend of mine, which wanted to demonstrate her abilities of graphic design. I really enjoyed working on that page, because I could try out some gimmicks. One of them was a the fact that she is now able to configure almost every page by XML and the icons are loaded automatically (matching to the config). Another thing was a diagonal menu, wherefore I just had the idea of an imagemap and some attached mouseover effects.

Spielefinder.Net

image

On a party one evening I talked to my girlfriends brother and asked him about some tools the web is still missing. I wanted to write a new project as a little training, but it needed to be a project which didn't already exist. During our conversation about verious ideas, he got me on the point of a game database. There're many of them, but none allows to filter the games by hardware. So about a week ago I got a page online which was able to filter its database for a specific hardware setup. Over that the client is able to specify a tolerance via some sliders (from the ASP.Net ajax toolkit) for the case they want to upgrade their PCs.

Codeplex - DownloadCounter

And last but not least: I added a new project to Codeplex named "DownloadCounter". At the moment it's just a very simple assembly and a demo project. I started that project, because the boyfriend of my sister asked me if I could put some files online for download and I decided to give him the ability to track how many times these music tracks where downloaded (he's a little hip-hopper) so that he can measure his success (or not :-D). And because I already wrote several download counters, I thought I could write one in .Net which was reusable and put it on Codeplex so that it can be improved over time - so I'm now hoping that some guys will download it and give me some good hints for improving it.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Token not yet valid

clock May 15, 2008 20:50 by author Divi

Some days ago I got the security token project back to the surface (from the deepest part of my repository) to use in in another current project. Unfortunately I got an error message as I started the project for the first time. I didn't know where it came from, so I went through the code step-by-step. Fascinated I recognized that it didn't appear again. I reloaded the page several times, but everything seemed to work fine. Because of this I thought it would have been a cache problem and forgot it.

Some hours later I had deleted my cookies and tried to issue myself a new token - but there the error was again - and again it disappeared during the step-by-step debugging.

Because I couldn't find a specific reason for this I spread several breakpoints all over the code and just hopped from one to the next to narrow the place of the exception. As I finally found the place in the code, I got the following error message:

"The SamlToken is not time valid. The current time "5/14/2008 11:29:21 AM" is outside the Effective "5/14/2008 11:29:59 AM" and Expiration "14.06.2008 11:29:59" time of the token.

image

What happened? First I guessed that there could be a bug in the calculation of the date, until I recognized: The token was valid some seconds AFTER the issuing. But why? Could that be a build in method?

After some research in the internet I found someone who had the same problem. He already had answered the question for himself: "I think I should correct the time of the server" ... right ... there was a time difference of 30 seconds between my PC and the dev-server I used - that has been the reason why the token was not YET valid as I it was issued to me - and this was the reason why I couldn't find it as I went through the code step-by-step, because I needed a longer time to step through than the differnce between both machines.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Capture process output

clock May 3, 2008 22:39 by author Divi

As I recently worked on a private project, where I had to compare several files with each other, I also came across the integrated "Diff" method of SVN. To compare two files, you can call the SVN with the following command:

svn diff -r OLD_REVISION:NEW_REVISION FILE

and you get instantly your output in the diff-format.

 

To call SVN I wanted to start the process from an ASP.Net class in the background and capture the output. Unfortunately I got a problem. The output seemed to be empty all the time.

As I tried the same thing some days later, I suddenly got the desired output. When I came home, I replaced my old code with the new one, but again the output remained silent. Because of this I started to compare both applications (my test app and the app for the file comparison). At first I thought Vista would suppress the output, because the PC on my workplace has XP installed on it, while my private PC has Vista, but this seemed to be the wrong reason, because it also didn't work as I executed the testapp from my "work"-PC on my private one... But that was the moment I recognized it. The difference was the application type: While my project itself was a web application, the test project was a Consolen application.

This is the code I used: 

 

ProcessStartInfo ps = new ProcessStartInfo("svn", "diff -r 4:6 file:///MY_LOCAL_FILE");
ps.UseShellExecute = false;
ps.RedirectStandardOutput = true;

Process p = new Process();
p.StartInfo = ps;
p.Start();
p.WaitForExit();

string output = p.StandardOutput.ReadToEnd();

 

The string "output" was always empty (not null), while the console application showed the right output:

 

Console:

image

Web application:

image

 

That problem I had to solve, because I didn't want to use a desktop application. So I tried several things. At first I thought there would be problems with the TrustLevel of the application and that the web application was more restrictive, but no matter which changes I made at the security settings, there was no change, until I found a code snippet, which I copied 1:1. It worked in the web application, but when I reduced the copied code to the needed parts by removing the "senseless" stuff, it didn't work again... So I took the code from the internet and removed line-by-line to find out which of the lines made the clue - in this way I found the reason:

The magic property was "RedirectStandardError". As soon as I changed its value to "true", everything worked fine:

image

 

HINT:  

As I started to write this blog entry, I first wanted to use another application than SVN, so I chose "PING" (because it's available everywhere). Interestingly it worked without any problems:

image

So obviously it depends also on the type of the called application, if you have to change the property or if it works also without.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Various 20080406

clock April 6, 2008 15:28 by author Divi

In the last time I haven't had much time to work on my blog or some of my private sites, because at my job we've (fortunately) very much work to do which is sometimes (unfortunately) a little bit short of time.

To not open a larger theme in here, which I'd like to explain much more detailed, but wouldn't have the time to, I decided to just post some things that I found during the daily work of the last weeks:

 

VSO DivxToDVD

Some days ago I was asked to get a very debatable video from the internet on DVD, because a friend of mine has no computer to use the internet himself or at least watch the downloaded video. After some flops of software I tried, I was guided by Google to the page of Softonic, where I found the VSO DivxToDVD Converter 0.5.2.99. It's a pretty cool tool, simple to use and free:

image

As I went to the producers page to check out for some updates, I found out (to my regret) that the nice (and, much more important, free ;-D) Tool became fee required. I think it's a good thing that VSO decided to bring it to the market, because I really like that tool, but I don't want to pay for it as long as I just need it from that rarely. The new name of the tool is ConvertXToDVD and costs about 40€.

(Hint: Softonic still offers the link to the old, free version).

 

SDP Multimedia

As I was searching for the solution of a problem during the last week, I found a webcast which I'd like to watch, but which had no download link. It seemed as if there'd be some very interesting infos inside of it, but because it was to long, I tried to download it on various ways (which didn't actually work) - until I found the stream ripper SDP Multimedia.

image

It's a little bit slow while downloading (or perhaps it has just been the streaming-server :-D), but in any case: It's also free!

You only need to add a stream via the MMS protocoll and instantly the SDP starts downloading it to your harddisc.

 

FileSystemWatcher

At work we're using VisualCron since several months to do our filesystem-based cronjobs. Some days ago I found out that that the .Net framework allready offers a helper class, which can be used to do exactly this thing: System.IO.FileSystemWatcher.

This object allows you to watch filesystem and react on various events (e.g. changes, updates,...). Therefore you only have to instantiate the object, choose the directory to watch, (optionally define a file mask (e.g. to just react on .cs-files)) and to tell the object to start watching:

 

System.IO.FileSystemWatcher fsWatcher = new System.IO.FileSystemWatcher();

fsWatcher.Path = @"C:\fsWatcherTest";
fsWatcher.Created += new System.IO.FileSystemEventHandler(FileCreated);
fsWatcher.WaitForChanged(System.IO.WatcherChangeTypes.Created);

 

With this code, you get the FileSystemWatcher to wait for the creation of exactly one file and call the method FileCreated afterwards. To react on the renaming of this file - and this not once, but several times, I extended the program in the following way:

 

class Program
{
    static void Main(string[] args)
    {
        System.IO.FileSystemWatcher fsWatcher = new System.IO.FileSystemWatcher();

        fsWatcher.Path = @"C:\fsWatcherTest";
        fsWatcher.Created += new System.IO.FileSystemEventHandler(FileCreated);
        fsWatcher.Renamed += new System.IO.RenamedEventHandler(FileRenamed);

        while (true)
        {
            fsWatcher.WaitForChanged(System.IO.WatcherChangeTypes.Created);
            fsWatcher.WaitForChanged(System.IO.WatcherChangeTypes.Renamed);
        }
    }

    static void FileCreated(object sender, System.IO.FileSystemEventArgs e)
    {
        Console.WriteLine(String.Format("File Created: {0}", e.FullPath));
    }

    static void FileRenamed(object sender, System.IO.RenamedEventArgs e)
    {
        Console.WriteLine("---");
        Console.WriteLine("File Renamed:");
        Console.WriteLine(String.Format("Old path: {0}", e.OldFullPath));
        Console.WriteLine(String.Format("Old name: {0}", e.OldName));
        Console.WriteLine(String.Format("New path: {0}", e.FullPath));
        Console.WriteLine(String.Format("New name: {0}", e.Name));
        Console.WriteLine("---");
    }
}

 

After I entered the code I did the following steps

1.) Started the program.

2.) Created a text file in the specified directory.

3.) Renamed the newly created text file.

This caused the following output:

image

 

Interesting: If I create a new file on Vista via right clicking, I get a new file where the file name (without the extension) is marked, to ease the renaming. As I just said - the file is firste created an renamed later on (as can be seen at the image above). So take care that a file you handle might not have its final name after the creation.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5