?
Solved

Need pseudo-code

Posted on 2008-06-14
8
Medium Priority
?
508 Views
Last Modified: 2008-06-20
Hi there,

I am a newb to programming and need some pseudo-code to get me started. I know it doesnt make a diff with pseudo-code but im planning to write this in c#.

Now i am planning to write a application proxy or servlet which will query a web service and return world time zones from this website.

http://worldtimeengine.com/api

Then javascript from my website (do not need pseudo-code for js) will query the results from the application proxy or servelet, so basically it is a seperate app from my website but will sit on the same server.

I have been given this guide from a previous posting but i dont know where to start (ie call the webservice) and which of the examples it implement.

Please ask me any questions on this if i have not explained clearly.

Thanks in advanced.
0
Comment
Question by:irfo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 5

Expert Comment

by:coldboy
ID: 21787412
Which .NET Framework are you working on? If it 3.5, then it's very easy.
Read the article here: http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=264
and then you can start in a minute.
0
 

Author Comment

by:irfo
ID: 21789330
Hi there,

its .NET 2.

Still  as easy?
0
 

Author Comment

by:irfo
ID: 21789459
Hi,

Is asking for pseudo-code too much for one question.

Just need to know if i need break question up into smaller chunks as im not getting much response.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:irfo
ID: 21789463
Hi,

Is asking for pseudo-code too much for one question.

Just need to know if i need break question up into smaller chunks as im not getting much response.
0
 
LVL 5

Accepted Solution

by:
coldboy earned 2000 total points
ID: 21812760
Dot NET 2.0 is still possible (though it much simpler with .NET 1.0).
About pseudo code, I'm not very sure, because you have to deal with web.config also.
Any way, here is an instruction. It's may not complete as I do not work much on 2.0 now.

First, search for "AJAX Extensions for net 2.0" and you will be able to download ASP.NET AJAX 1.0
Second, add these settings to your web.config:
1.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <configSections>
            <section name="UploadModuleManagement" type="UploadModule"/>
            <section name="rewriter" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
            <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                  <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
                              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
                              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
                        </sectionGroup>
                  </sectionGroup>
            </sectionGroup>

2.
<system.web>
            <httpModules>
            <compilation>
                  <assemblies>
                        <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </compilation>
            <httpHandlers>
                  <remove verb="*" path="*.asmx"/>
                  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
            </httpHandlers>

Up to that time, your webservice can be invoke via javascript with input and output in form of JSON syntax.

Next, write a web service. Here is an example:

using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
    [ScriptService]
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class HelloWorld : System.Web.Services.WebService
    {

        public HelloWorld()
        {

            //Uncomment the following line if using designed components
            //InitializeComponent();
        }

        [WebMethod]
        public string TalkToMe(string what)
        {
            return "You ask " + what;
        }

    }
}

And, finally, build the request component:
The easiest way is to use a Javascript framework. I use prototype, you can obtain a copy of prototype at prototypejs.org. Prototypejs provide a class named Ajax.Request to handle ajax request, we will use it for communicate with web services.

After include prototype.js, you can make a web service call:

function requestOK(result){
      alert(result.responseJSON)
}
function invoke: function (){
        var options = {
            method: "post",
            onSuccess: requestOK,
            postBody: {param: "How can this work"},
            contentType: "application/json"
        }
        return new Ajax.Request("HelloWorld.asmx/TalkToMe", options);
    }


As you can see, it will require alot of work. And you must done every thing correctly in order for it to work.
I know you are asking for pseudo code, I cannot give you any, because it about detail.
Now follow the step above, and you should have a wonderful web service.
Cold
0
 
LVL 5

Expert Comment

by:coldboy
ID: 21819622
There is a mistake on the javascript code above.
change it:
function invoke: function (){
        var options = {
            method: "post",
            onSuccess: requestOK,
            postBody: "{param: \"How can this work\"}",
            contentType: "application/json"
        }
        return new Ajax.Request("HelloWorld.asmx/TalkToMe", options);
    }
0
 

Author Comment

by:irfo
ID: 21835367
Thank you so much for taking the time to code the code.

Much appreciated.
0
 

Author Comment

by:irfo
ID: 21835373
Sorry,

Post the code.
0

Featured Post

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question