download please

Jaspreet Bakshi

Engineering Empowers

Posts

  • June 23, 12:16 AM

    NYC Startup Weekend

    I recently attended the NYC Startup Weekend. Initially I was reluctant thinking it would be a waste of time, not productive etc, but I was surprised. It was an awesome experience, and after the chaos of Friday night, Saturday and Sunday were exciting days when I worked in a team of 5 people to come up with an interesting concept, and also picked up some Android/Java  programming.

    Our idea “Sound Spot” got a shout out from the Technoverse Blog. Thank You!!

    Overall the quality of  pitches was excellent and it was a learning experience through and through. Everything thing from what VCs look for, to how to appeal to an audience, to a completely new platform for development. I highly recommend attending one if possible.

    Besides all this there was excellent food at the event (surprisingly I must admit). It was served by Organique. So good!!!


    Filed under: collaboration, Mobile, startup Tagged: nyc startup weekend, sound spot
  • May 17, 09:38 PM

    NAnt, NAntContrib & How can I use msbuild with NAnt?

    I had a simple need…

    I wanted to check if my NAnt .build file changes were correct before checking them into source control. We already have Cruise Control.NET setup and it works but I did not have any way to test my changes locally. So I thought I would install NAnt and try to test my changes.

    So there I went… at first I googled my way to nant.sourceforge.net and found NAnt binaries. Downloaded them, unzipped them and tried to run nant.exe on my build file. Failed. Then I googled my way to discovering that I need something called NAntContrib because it has the definition of the task msbuild that I was using in my .build file. OK so I downloaded NAntContrib. But it wasn’t clear what I should do next. How could I tell nant.exe to load the definition of the msbuild task from NAntContrib binaries?

    Anyway, I figured it out (we always do) but had to struggle and google my way around a lot of stuff to get to the point where I was able to run everything.

    Here are simple instructions I wish I had. Hopefully they help you out if you’re stuck with the same issue.

    What is NAntContrib?

    From the NAntContrib readme.txt

    “NAntContrib is the project for tasks and tools that haven’t made it into the main NAnt distribution yet or for whatever reason don’t belong there.”

    How can I install NAnt and NAnt contrib on my machine?

    1. Install NAnt

    • Get the latest Release from here: http://nant.sourceforge.net
    • You can just get the binaries in zip form and unzip on a folder in your machine (say c:\Program Files\nant)

    2. Install NAntContrib

    • Get the latest release from here: http://nantcontrib.sourceforge.net
    • Again you can download the binaries in zip form and unzip into a folder in your machine (say c:\Program Files\nantcontrib)

    How can I use tasks from NAntContrib in my NAnt?

    I was trying to use msbuild which is a task to build a Visual Studio Solution (.sln) file. Here is how I got it to work.

    This is how I defined my “build” target in the my .build file

    <target name="build" description="Compiles the .Net solution">
          <!-- build the solution -->
          <echo message="Building ${project::get-name()} v${project.version}" />
          <!-- need nant.contrib.tasks.dll for msbuild -->
          <loadtasks assembly="C:/Program Files/nantcontrib/bin/NAnt.Contrib.Tasks.dll" />
          <msbuild project="mysolution.sln">
                <arg value="/p:Configuration=${target}" />
                <arg value="/p:Platform=Any CPU" />
                <arg value="/t:Rebuild" />
          </msbuild>
    </target>

    By adding the tag in there with the path to the NAnt.Contrib.Tasks.dll, I point nant to the dll to find the msbuild task and it just works.

    The command line to run nant on the build file was as follows

    c:\Projects\myproject>"c:\program files\nant\bin\nant.exe" -buildfile:mysolution.build build

    This tells nant.exe to find mysolution.build in the current folder and execute the “build” target in it.


    Filed under: development tools Tagged: cruise control, nant, nantcontrib
  • March 20, 12:25 AM

    MooTools Request.JSON “success” event – Some Undocumented Behavior

    Request.JSON is a simple extension of the Request class that MooTools provides for making HTTP request. According to the MooTools documentation for the Request.JSON class the handler for the “success” event will receive two arguments. The first one being the response JSON object, and the second, the response in text form. The signature of the handler function would then be something like this:

    OnSuccess(responseJSON, responseText)
    

    Now when a request is made without any arguments, like below

    var req = new Request.JSON(
    {
        method: method,
        url: url
    });
    
    req.addEvent("failure", failurefn);
    req.addEvent("success", successfn);
    req.send();
    

    that is indeed the case. The success function gets the responseJSON and the responseText.

    However if the request includes arguments, like so:

    var req = new Request.JSON(
    {
        method: method,
        url: url
    });
    
    req.addEvent("failure", failurefn);
    req.addEvent("success", successfn);
    req.send(args);
    

    the 2 arguments to the success function are first the response JSON object and second the arguments (args) that were originally passed into the request. In other words the signature of the success function is like this:

    OnSuccess(responseJSON, args)
    

    I couldn’t find any mention of this in the MooTools documentation, and I think this might be a behavior of the underlying XmlHttpRequest object itself and not something introduced by the MooTools class.


    Filed under: JavaScript, Mootools Tagged: request.json, xmlhttprequest
  • March 17, 01:57 AM

    Windows Phone Developer Tools

    On 03/15/2010, at Mix 2010, ScottGu announced the availability of Windows Phone Developer Tools CTP for free download. It can be downloaded from here

    http://www.microsoft.com/downloads/details.aspx?FamilyID=2338b5d1-79d8-46af-b828-380b0f854203&displaylang=en

    And more information about the download can be found here on the Windows Phone Developer Blog.

    Also the developer home for Windows Phone is here

    http://developer.windowsphone.com

    While installing the download package, I ran into an error that VC 10.0 was already installed. Turned out that I had Visual Studio 2010 Beta 1 installed on my machine, and the Windows Phone Developer CTP was not OK with that. Uninstalling the VS 2010 Beta 1 fixed the issue.

    A bunch of other new technology that has been announced in Mix 2010 include

    oData – Open Data Protocol. A new protocol built on HTTP and ATOM for sharing data based on REST principles. It was earlier known as ADO.NET Data Services. There’s a feed for that!

    - Dallas - A market place for web API providing access to data sets using oData. Many datasets already available. Again more information about this here, on the Dev Blog.

    - Houston – A tool built in Silverlight that allows manipulation of SQL Azure. Again this is not something new but things are coming together nicely for developers working with Microsoft technologies.


    Filed under: Mobile Tagged: ado.net data services, dallas, houston, mix 2010, odata, windows phone, windows series 7
  • March 08, 06:21 PM

    Quickly finding WCF Serialization/Deserialization Issues

    Once control leaves your code, and heads into the land of WCF serialization, or before it hits your code, when it is in the land of WCF deserialization, you usually don’t have much insight into what’s going on. Yes, you can write your own handlers and step into the process but in most cases, there is no need for that. All you need is a little bit of logging and some error messages to help you catch issues.

    Fortunately, Visual Studio comes with a handy little tool called SvcTraceViewer.exe that can help you quickly find issues with serialization or deserialization of your DataContracts.

    You need to do the following two steps to quickly find the issue:

    Step 1

    Tell WCF to start logging out into a file. You can do this by adding the following diagnostic section as a child of the <configuration> tag. But be careful, it has to be after the end of the <congifSections> tag. There are a lot of options and flexibility WCF provides around this tracing, and you can read all about it here. The section below will cause WCF to log out its activity to the file c:\wcf.svclog

    <system.diagnostics>
        <sources>
            <source     name="System.ServiceModel"
                        switchValue="Information, ActivityTracing"
                        propagateActivity="true">
                <listeners>
                    <add    name="traceListener"
                            type="System.Diagnostics.XmlWriterTraceListener"
                            initializeData= "c:\wcf.svclog" />
                </listeners>
            </source>
        </sources>
    </system.diagnostics>
    Source: http://msdn.microsoft.com/en-us/library/ms733025.aspx

    Step 2

    Now that you have set WCF to log out all its activity into c:\wcf.svclog, all you need to do it open that file using the utility SvcTraceViewer.exe. It ships along with Visual Studio (atleast VS 2008 Professional Edition that I have), and it lives in the following folder on my machine.

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

    Once you open the trace file in SvcTraceViewer.exe, you will see the log entries (activities). Something like this:

    Here you can see that a number of activities are logged and also a couple of errors are pointed out in red.

    When I click on one of those error entries, this is what I see on the right side of my SvcTraceViewer window:

    As you can see, all the steps for processing that particular request are listed, and the step that failed is logged out in red. When I click on the step that failed, this is what I see in the bottom pane of my SvcTraceViewer window:

    As you can tell from the “Message” field under the “Exception Information” section, the error is pretty clear. While attempting to fulfill a request, WCF ran into an interface that was actually implemented by a type it did not recognize (WLogicTree). I need to tell it about the type. I can do this by adding it to the ServiceKnownTypes list.

    In short, once you know how to use tools like SvcTraceViewer, and understand some of WCF rules for serialization and deserialization, it is not very painful to catch most errors.

    Happy debugging!


    Filed under: web services Tagged: svctraceviewer, wcf
  • March 06, 07:30 PM

    Thoughts on SharePoint/SocialCast Integration

    SocialCast recently announced a Sharepoint Webpart, a part of their EASE release. I think some of the connectors, specially ones that bring SocialCast to Outlook and SharePoint will be very useful. I was also thinking about the reverse, which is bringing content from sources like Outlook and SharePoint into SocialCast (just like it allows bringing content from Twitter and Facebook).

    Below are some thoughts about how such an integration could work.

    SharePoint organizes everything in terms of sites, sub sites and lists. For example if I have a sharepoint site for my group (a set of engineers and PDs who work together organizationally), one way to organize my projects would be to create a site for each project under my group’s site. Inside a site, you can have any number of lists. List is the generic term sharepoint uses for any set of information. So Links, Announcements, Events and Documents etc are all lists within a sharepoint site. People usually associate webparts with Sharepoint but webparts are just a user interface concept, used to surface all or parts of underlying lists, and other information. The underlying data is all stored in terms of lists.

    For SocialCast/Sharepoint integration, it would be good to have an interface where I can point to a top level sharepoint site, and see all the sites that are under it, and then select a site, and see all the lists that are under it. Then for each list, see all actions that are possible on the list, and be able to turn on/off notifications for each action. It would also be great to have the same notification features at the site level, meaning being able to turn on/off notifications for the whole site (i.e. all lists and sub-sites under it).

    Subsequently, each time a notification is generated, it should have information about which site, list and item it is being generated for (including a link to the item), the kind of action being performed, and the user that performed the action. It would also be nice to have other useful fields of information associated with the change that sparked the notification such as Comments.

    I can imagine that such automated notifications could easily clutter the “Company” or “Home” activity stream, so maybe there should be an option to see or not to see such notifications there. The same could be said for all stream items that are auto-generated (though some people may prefer those over person generated stream items

    Consider this scenario…

    Lets say I belong to a organizational group (Org Group) in my company called the “Company Data Group” and I am currently working on a project called “Fundamentals Integration”. I have a SharePoint site for my entire Org Group, and a sub-site under it for the current project I am working on. To help my Org Group collaborate, I also create a SocialCast Group (SC Group) called “Company Data Group” and include all members of my Org Group in it. Since the concept of projects is not directly supported in SocialCast, I would make another SC Group (maybe a private SC Group) and include all the people who are working with me on that project.

    Now, I should be able to configure the stream settings for the SC Group that maps to my current project to include notifications that are being generated from that Sharepoint site for my current project (just like I am able to do so for twitter feeds being imported to the stream). Then the stream on my SC Group will be in sync with the activity going on in my project’s sharepoint site, and I will easily be able to keep on top of it.

    Groups Vs. Workspaces/Projects

    I think if we are talking about Sharepoint integration we must address the issue of Groups vs. Workspaces/Projects.

    I associate SocialCast Groups with permanent organizational entities, like the “NYC Outreach Group” or the “Internal Communications Groups”. That makes sense but how does Socialcast support collaboration on a certain project or short term event, say a charity event being organized to support Chile or a market research project to identify the impact of a new product? How do we define the boundaries of that project, meaning I don’t want the content generated as a part of that project (messages/docs/links etc) to mix with other projects that I may have worked on or will work on.

    Since I cannot make a “workspace” for my Project under my Group, the only option I will have is to make a Group for every Project I work on, and eventually that will lead to a lot of clutter (think thousands of Groups). It helps that Groups can be private and invitation only, so atleast my project groups will not clutter other people’s socialcast views. Also, I guess I could use a unique tag for every Project and make a stream that filters on that tag. But that seems fragile, as some people may not add those tags.


    Filed under: Enterprise Collaboration Tagged: sharepoint, socialcast
  • March 01, 08:00 PM

    Serializing and Deserializing derived types or interfaces in WCF

    Often you will have the case where you can take as input into a WCF operation contract a base type, which could be one of many derived types, or an interface that could be implemented by many

    different classes. Similarly you could be returning a base type or an interface. WCF supports those scenarios fairly well, and is able to handle serialization and deserialization for them.

    However, you have to do a few extra things to provide WCF the extra information it needs to work correctly. This blog will tell you what they are…

    Lets say I have a service defined like this:

    namespace MyNamespace
    {
        [ServiceContract]
        public interface IMyServiceInterface
        {
                [OperationContract]
                [WebGet(UriTemplate = "MyObjects",
                  ResponseFormat = WebMessageFormat.Json)]
                BaseResponse GetMyObjects(uint projectID,
                                           BaseRequest breq);
        }
    
        // Here BaseRequest and BaseResponse are 2 base classes 
        // and lets say each has 2 derived classes:
        [DataContract]
        public class BaseRequest
        {
            uint reportID;
        }
    
        [DataContract]
        public class DerivedRequest1 : BaseRequest
        {
            uint componentID;
        } 
    
        [DataContract]
        public class DerivedRequest2 : BaseRequest
        {
            uint screenID;
        }
    
        [DataContract]
        public class BaseResponse
        {
        }
    
        [DataContract]
        public class DerivedResponse1 : BaseResponse
        {
        } 
    
        [DataContract]
        public class DerivedResponse2 : BaseResponse
        {
        }
    
        // Lets say the implementation of that 
        // service is like this:
        public class MyService
        {
            public BaseResponse GetMyObjects(uint
                          projectID, BaseRequest breq)
            {
                BaseResponse bres = null;    
    
                if (breq is DerivedRequest1)
                {
                    bres = new DerivedResponse1(projectID);
                }
                else if (breq is DerivedRequest2)
                {
                    bres = new DerivedResponse2(projectID);
                }
    
                return bres;
            }
        }
    }

    Now the question is how does WCF know to serialize DerivedResponse1 and DerivedResponse2, and deserialize DerivedRequest1 and DerivedRequest1?

    Firstly you have to tell it using the KnownType attribute on the base contracts themselves. Something like this:

    [DataContract]
    [KnownType(typeof(DerivedRequest1))]
    [KnownType(typeof(DerivedRequest2))]
    public class BaseRequest
    {
    } 
    
    [DataContract]
    [KnownType(typeof(DerivedResponse1))]
    [KnownType(typeof(DerivedResponse2))]
    public class BaseResponse
    {
    }

    That should be enough to get it to serialize DerivedResponse1 and DerivedResponse2 but for an incoming request, it does not know which derived request to deserialize to.

    Lets say this is how we are making the call to the service from Javascript (using Mootools):

    
    var args = new Object();
    args.projectID = 2;
    args.breq = new Object();
    args.breq.reportID = 4;
    args.breq.componentID = 3; 
    
    var req = new Request.JSON(
              {
                  url: 'myserviceurl',
                  headers: { 'Content-Type': 'application/json' }
              }); 
    
    req.addEvent("success", successfn);
    req.addEvent("failure", failurefn);
    req.send(JSON.encode(args));

    This will fail because WCF will not know that the breq object there was actually meant to be DerivedRequest1. It has to be told that. You can do that by adding a special “__type” (thats a double underscore) member to the breq object. Something like this:

    var args = new Object();
    args.projectID = 2;
    args.breq = new Object();
    
    // Specifying the type of the object as it
    // can be of multiple types 
    args.breq.__type = "DerivedRequest1:#MyNamespace"; 
    
    args.breq.reportID = 4;
    args.breq.componentID = 3; 
    
    var req = new Request.JSON(
              {
                  url: 'myserviceurl',
                  headers: { 'Content-Type': 'application/json' }
              }); 
    
    req.addEvent("success", successfn);
    req.addEvent("failure", failurefn);
    req.send(JSON.encode(args));

    Now this will work correctly with WCF being able to correctly deserialize breq into DerivedRequest1. The same holds true if instead of the base types you had interfaces that were being implemented

    by multiple classes. With the extra information provided by using the KnownType attribute and the “__type” member, you can get the behavior you expect.

    Now you can use a client side stub generator, especially if you’re not making the request from JavaScript and you wont have to deal with the “__type” variable, as the stub should be able to insert in that for you.


    Filed under: JavaScript, Mootools, web services Tagged: derived types, knowntype, wcf
  • January 18, 12:37 PM

    Hitting a WCF service from a Perl script on Linux, using JSON::RPC

    Another post to show how different platforms can be connected together using services. I feel these kinds of examples are important to get buy in for Service Oriented Architectures within the enterprise.

    I wrote up a little perl script running on linux that hits a WCF service installed on a windows box (running an IIS web server). In the script I use JSON::RPC, a freely available Perl module.

    To run it you need to install 2 perl modules: JSON and JSON::RPC. I also use the Data::Dumper module to print out the results but you don’t have to. You can just write out the results on the screen using Perl’s print function.

    Once you have the modules installed, here is the script that hits the service.

    #!/usr/local/bin/perl
    use JSON::RPC::Client;
    use Data::Dumper;
    my $client = new JSON::RPC::Client;
    # URL for the WCF service
    my $uri = 'http://myserver.com/services/myservice.svc/myservicemethod;
    
    # args to the service request, already jsonized
    my $obj =  {"ReportID"=>1,"projectID"=>126};
    # make the call
    my $res = $client->call($uri, $obj);
    
    if($res)
    {
        if ($res->is_error)
        {
            print "Error : ", $res->error_message;
        }
        else
        {
            # everything looks good... print the response
            print Dumper($res);
        }
    }
    else
    {
         print $client->status_line;
    }

    Steps for installing required Perl modules

    Here are some steps for installing the above mentioned Perl modules in your user directory, if you don’t have permissions to install them in your root directory. Download the tar files for the modules. Then:

    cd ~

    tar xzvf <name of tar file>

    cd <untared directory>

    perl Makefile.PL PREFIX=/home/user/<your user dir>

    make

    make install

    setenv PERL5LIB /home/user/<your user dir>/lib/perl5/site_perl/5.8.5


    Posted in web services Tagged: json, perl, wcf
  • January 11, 07:54 PM

    More on the war to control the web

    One of the biggest wars going on in the tech world is about who will control the platform for web development.

    The main players:

    • Microsoft (via Silverlight)
    • Adobe (via Flash)
    • Google (via HTML5)

    Adobe’s Flash platform is by far the most common platform for RIAs, even in the enterprise. Here are some numbers (published by adobe)

    Source: http://www.adobe.com/products/player_census/flashplayer/enterprise_penetration.html

    HTML5 is being touted as the next big thing, and with Google backing it, it may be.

    However this tweet by Scobleizer caught my attention:

    Reading the latest drama about HTML5 it seems like Silverlight has a chance to make major inroads this year: http://bit.ly/8qcoNn. Sigh.

    As someone who is affected by the outcome of this war, my advice is to build service oriented architectures where you don’t tie yourself to one of these technologies.


    Posted in web services Tagged: flash, flex, html, silverlight
  • October 15, 04:43 PM

    Calling WCF Services from a Linux C++ Client Using gSOAP

    Before I get into part II of my earlier post about Configuring and Debugging WCF Services, I want to write about a problem I solved recently. Took a lot of digging around and so I thought I would save someone time by making this post.

    Disclaimer: I am primarily a Windows Developer. I usually don’t have any issues going between platforms, languages and such but by no means am I an expert on the Linux platform (or on SOAP for that matter).

    The Motivation

    The basic problem I was trying to solve was trying to hit a WCF service from Linux using C++. Why was I doing that you might ask. Well, in most environments out there today, programmers and architects have to make heterogeneous systems work together and deal with  legacy systems that will not die (the reasons are many, and complicated).

    Service Oriented Architectures come with the promise of making this integration between different platforms easy to achieve, maintain and evolve. However, choosing the technologies to implement SoA in is an important decision, as to be useful, the services you create should be accessible from every platform easily. Only then will you get the buy in needed for SoA to succeed.

    gSOAP

    gSOAP is a technology that allows you to create stubs for client and server side code from WSDLs. There is a lot more that gSOAP can do but I only used it for creating the client side stubs using the WSDL I got from my WCF service.

    You can read all about it here.

    Making it Work

    OK, let’s get down to how we can use gSOAP to access a WCF service using a C++ client. The steps I had to take were

    1. Install the gSOAP library on my Linux box, in my local directory
    2. Generate the SOAP stubs for the target WCF service
    3. Create the client

    Here are the steps again with many more details:

    Install the gSOAP library

    1. Download the gSOAP tar file. The website is here.

    > wget http://sourceforge.net/projects/gsoap2/files/gSOAP/2.7.14%20stable%20%28update%29/gsoap_2.7.14.tar.gz/download

    2. Untar the file.

    > tar -xvzf packagename.tar.gz

    3. Make and install. Run the following commands.

    > ./configure

    > make

    > make install exec_prefix=$HOME // This is to get it installed on your local drive

    Generate the SOAP stubs for the target service.

    I installed gSOAP in my home directory. Also lets assume that the service I am trying to connect to exposed an endpoint with BasicHttpBinding, which boils down to simple SOAP. And it is located at the following address

    http://www.myserver.com/myWCFservice.svc

    and the method I am trying to invoke has the following signature:

    int IMySevice.GetCount(string inputString)

    // The service implements the IMyService interface and the interface has the GetCount method on it

    You would need to execute the following commands to get your SOAP stubs:

    Go to the appropriate directory for the platform you are on.

    > cd <home dir>/lib/gSOAP/gsoap-2.7/gsoap/bin/linux386

    Generate the WSDL header file.

    > ./wsdl2h -o mywcfheader.h http://myserver.com/myWCFService.svc?wsdl

    Generate the stub files by executing the gSOAP compiler

    > ./soapcpp2 -I”<home dir>/lib/gSOAP/gsoap-2.7/gsoap/” mywcfheader.h

    At this point you should have the stub files in you directory. As far as the client is concerned, you care about these files

    File Name

    Description

    BasicHttpBinding_IMyService.GetCount.req.xml Example SOAP Request
    BasicHttpBinding_IMyService.GetCount..res.xml Example SOAP Response
    soapBasicHttpBinding_IMyServiceProxy.h C++ Proxy that wraps the SOAP calls that are made on the client side into an Object Oriented interface. The client you write will consume this.
    BasicHttpBinding_IMyService.nsmap File that defines the name space (for versioning of the SOAP protocol) of various schema prefixes
    soapC.cpp, soapClient.cpp, soapClientLib.cpp, soapH.h and soapStub.h Client Side SOAP Code that the C++ proxy consumes

    Create the client.

    The client code is pretty simple. It looks something like this:

    // This will be the name of the proxy file created when
    // you generate the stubs
    #include “soapBasicHttpBinding_IMyServiceProxy.h”
    
    // This will be the nsmap file created when you created
    // the stubs
    #include “BasicHttpBinding_IMyService.nsmap”
    
    using namespace std;
    
    int main()
    
    {
        // This will be the name of the service
        // class in the proxy header file from above
        BasicHttpBinding_IMyService s;
    
        // This is the request and response that
        // the service you are trying to call takes.
        // Again you can find the types in the class
        // used in the C++ proxy header
        _ns1__GetCount req;
        _ns1__GetCountResponse resp;
    
        string is(”Hello There America”);
        req.inputString = &is;
    
        int err = s.__ns1__GetCount(&req, &resp);
    
        if (SOAP_OK == err)
            cout << “Service Returned: ” << *resp.GetCountResult << endl;
        else
            cout << “Error: ” << err << endl;
    
        return 0;
    }
    
    2: // This will be the name of the proxy file created when
    3: // you generate the stubs
    4: #include “soapBasicHttpBinding_IMyServiceProxy.h”
    5:
    6: // This will be the nsmap file created when you created
    7: // the stubs
    8: #include “BasicHttpBinding_IMyService.nsmap”
    9:
    10: using namespace std;
    11:
    12: int main()
    13: {
    14:         // This will be the name of the service
    15:         // class in the proxy header file from above
    16:         BasicHttpBinding_IMyService s;
    17:
    18:         // This is the request and response that
    19:         // the service you are trying to call takes.
    20:         // Again you can find the types in the class
    21:         // used in the C++ proxy header
    22:         _ns1__GetCount req;
    23:         _ns1__GetCountResponse resp;
    24:
    25:         string is(“Hello There America”);
    26:         req.inputString = &is;
    27:
    28:         int err = s.__ns1__GetCount(&req, &resp);
    29:
    30:         if (SOAP_OK == err)
    31:                 cout << “Service Returned: ” <<
    32:                     *resp.GetCountResult << endl;
    33:         else
    34:                 cout << “Error: ” << err << endl;
    35:
    36:         return 0;
    37: }
    38:

    Since our binding is BasicHttpBinding, the WCF service expects SOAP 1.1 as the protocol. By default gSOAP 2.7 talks in SOAP 1.2. So we need to make sure that we make changes required to generate a client that will communicate using SOAP 1.1.

    We can do this by changing the following in your *.nsmap and C++ Proxy header file. Change:

    {“SOAP-ENV”, “http://www.w3.org/2003/05/soap-envelope”, “http://www.w3.org/2003/05/soap-envelope”, NULL},

    {“SOAP-ENC”, “http://www.w3.org/2003/05/soap-encoding”, “http://www.w3.org/2003/05/soap-encoding”, NULL},

    {“xsi”, “http://www.w3.org/2001/XMLSchema-instance”, “http://www.w3.org/*/XMLSchema-instance”, NULL},

    {“xsd”, “http://www.w3.org/2001/XMLSchema”, “http://www.w3.org/*/XMLSchema”, NULL},

    to this

    {“SOAP-ENV”, “http://schemas.xmlsoap.org/soap/envelope/”, NULL, NULL},

    {“SOAP-ENC”, “http://schemas.xmlsoap.org/soap/encoding/”, NULL, NULL},

    {“xsi”, “http://www.w3.org/2001/XMLSchema-instance”, NULL, NULL},

    {“xsd”, “http://www.w3.org/2001/XMLSchema”, NULL, NULL},

    I found this information here.

    Compile the client

    Now we are ready to compile the client. Besides the client code you write and the stub files generated by gSOAP, we also need to supply the compiler with another file stdsoap2.cpp that comes with the installation. Also we need to add the gSOAP lib path to the include path so that it can pick up the appropriate libraries it needs.

    The command will look like this:

    g++ -I”<home directory>/lib/gSOAP/gsoap-2.7/gsoap” myclient.cpp soapC.cpp soapClient.cpp <home directory>/lib/gSOAP/gsoap-2.7/gsoap/stdsoap2.cpp

    At this point things should work. Leave comments if something does not work for you or if there are other ways to do this.


    Posted in web services Tagged: gsoap, linux, wcf

Posts

  • December 03, 12:06 AM

    Einstein Sez

    He had a lot of smart things to say but these are 3 really cool quotes from my man Einstein

     - If you are out to describe the truth, leave elegance to the tailor

    - Try not to become a man of success but rather to become a man of value

    - We should take care not to make the intellect our god; it has, of course, powerful muscles, but no personality

    Especially like the first one…

    Quotations found on The Quotations Page


  • May 18, 11:42 PM

    US Government: Lets be Smarter About Visas

    In the past few days I have been reminded twice of how much paperwork and bureaucracy is involved getting visas to work in and travel between countries. So much of what is a part of the process today is meaningless when it comes to establishing the eligibility for a visa and though there is a lot of technology being used, especially in the US immigration system, it is not being used smartly to avoid the time and productivity drain that people who have to go through it, endure.

    I’m not here to report a bad employee, but a bad process and an attitude that says, “hey we are already doing immigrants/travelers a favor, what else do you want from us”. My experience on the days I had to actually go into the consulates wasn’t that bad, that is after I had spent days getting all the paperwork together, getting paranoid double checking that I had everything, making arrangements at work for the days I would have to be away or busy taking care of things. It is no exaggeration to say that the process is mentally draining and when you have to do it over and over again (once in a couple of years), it can be really frustrating even for seasoned travelers/workers.

    Same information over and over and over again

    There are pieces of information that I must have entered at least a 100 times by now. Name, parents names, passport number, employment history, education history and a bunch of other stuff which is not going to change and if it will, there should be a process for managing that change, not a retarded process to force people to enter that information on every damn form that they fill out. Entering the same information again and again increases the chance that a person will make a mistake at some point and inconsistencies will start showing up. It’s almost as if the system is designed to make that happen. It’s as if the department of homeland security (or whatever) is saying, “we’re testing you on your ability to be able to bear the pain of writing out redundant pieces of information in various forms without ever making a human error. That’s the kind of person we want here”. After spending billions of dollars and introducing a huge layer of ineffective bureaucracy to track immigrants and foreigners, why don’t they just get the information from their databases? It seems like all of that infrastructure is there just to incriminate and not to help.

    Lets have some respect eh?

    Isn’t it irritating how the folks in most consulates (especially US consulates) think they’re personally doing a favor to those coming in to get visas. I feel like saying “dudes, I pay taxes too, so do the job I pay you to do and show a little respect”. They are not accountable for their behavior because of that clause in the visa rules that says [paraphrased], “Even if all your papers in order, everything is perfect, you are not guaranteed to get a visa. The final call is up to the consulate officer handling your application”. What that means is that it’s really up to them to show courtesy and do their job efficiently. If they don’t and you call them on it, they might just decide that something about you isn’t right and you should not get the visa. When I went to get my H1B visa stamped last time, there was a very courteous and cheerful lady officer who checked my papers (and I complimented her on her great attitude) and a really nice officer who interviewed me. However, in the past I have had dry, rude and condescending officers who look like they are just waiting for me to say something they don’t like or forget to bring some unimportant photocopy so they can send me back without a visa. I see the need for having trained personnel who are capable of making subjective evaluations about people, however I would like to see some tangible accountability and oversight that is visible and accessible to the people who have to go through the process. Is that too much to ask for in a country that prides itself for transparency and fairness and when we actually pay for the services?

    And what is it with the security people at these consulates… it’s like they are on a power trip of some kind, almost hilarious to watch them operate. Sure, US Consulates all over the world are under threat and you have to be alert and careful but shouting at the little old Chinese lady for not understanding what new security maneuver you are asking her to follow isn’t going to “secure our borders”.

    It’s getting worse all the time 

    It used to take a few hours to get your H1B visa stamped in 2004 in the US Consulate in Vancouver. In 2008, it is expected to take anywhere from 1 day to 4 working days, and most often it does take 3-4 days. You could pay cash (I think) for the visa processing fee in 2004. Now you have to go to Scotia Bank in Canada, deposit $131 there, get a deposit slip and submit that to the US Consulate. Why are things getting more and more difficult? Shouldn’t the model be around streamlining the process, and shouldn’t the cost to the people going to the process also be taken into consideration? Who is managing this process and where is the answerability? If this was someone in a private firm, they would be fired long ago… luck for them incompetence is a highly desirable trait in the Bush administration.

    That’s it for this rant…


  • April 08, 01:43 AM

    Little Drops Make an Ocean

    Saturday, 04/05/2008 was the “Night of Hope” organized by a charity called The Little Drops Orphanage Fund which was started by my friend and co-worker from Microsoft, Charles Duze. I dont find myself going to many charity events but this is one I have been going to for 3 years now. The reason, the people who run it are smart, dedicated and genuine, there is a cool African theme to the whole event and last but definately not the least there is home cooked African food, which this time Charles and his wife had themselves spend the whole day preparing. Thanks guys, it was delicious. No ordinary feat given that Little Drops has grown tremendously and I would say there were atlease 200 people who were at the event this year.

    Overall it was a great event as usual, marred by a few glitches in the sound system. Good thing Glen was the MC so we were distracted by laughing at him … just kidding bro… he handled it very well and made it work, besides what’s life without a little feedback eh?

    Most of the performance events were Indian, and althought they were pretty good, I was a wee bit disappointed. I was looking forward to hearing some African beats and watching some hot African dance moves like the last time… but no such luck. There was an excellent semi-classical santoor and tabla recital followed by 2 performances by Dreamz, a local Bollywood dance performance group. Not bad but I’ve seen them a few times now. There was a silent auction where I bid on and won a necklace which has a pendant shaped like Nigeria.

    There was a really touching speech made by one of the guests (I forgot his name). The parts that stood out most for me were when he said “you cannot solve a problem using the same mentality that has created it”  and second when he described starvation. He said that when the body starts to starve, it starts to feed on itself. First the fat, then the muscles and finally the organs. It does not know the difference. The complete hall became silent as they heard this. They probably pictured that happening to a little child.

    All in all the event organization could have been better but we had a blast. I strongly support Charles and his team’s efforts to make a difference in the lives of orphans in Africa. They are organizing a trip to a few African countries in 2009 so if you are interested in visiting, check out http://www.littledropsorphanagefund.org/trip/ and sign up.


  • February 12, 01:58 AM

    Snoqualmie Blues

    Summit at Snoqualmie sucks. There are a lot of people who think so for different reasons. Mostly these are people who know their way down the slopes and complain that the runs are too short or that there are too many people on them (those pesky little kids on skis… I actually think they’re cute). That may be true but the convenience of being able to drive to Snoqualmie within an hour definitely compensates for that. And they have a few decent runs which can be challenging. Guess what I’m saying is that I’m not really at a skill level to complain about that.

    What I do want to whine about is how badly managed the rental area is. And how they pulled a cheap little trick on me and robbed me of $33.33. Not to mention how obtuse some of the people who work there can be, but I guess that’s not really an issue unique to Snoqualmie.

    I went there one Saturday in Dec 2007 and bought a Ez 1-2-3 package that give you 3 days of lessons, rentals and lift tickets… awesome deal but I guess that’s how they compete in the market. As luck would have, they lost power (apparently that happens to them often) and after walking up the little green slope a couple of times, I decided to wind up for the day. No hard feelings, first time that season, a hiccup before the Snoqualmie machine starts up I thought… whatever. I asked and they said that yes, they would give me credit for an extra day as a part of the package.

    I go back there 2 more times, wait for more than an hour at the rental line each time, which could be much faster with a little reorganization of their space, even if they don’t add any additional employees there. But anyway, I get rentals and lift tickets and have fun on the slopes.

    Then I go there the 4th time (counting the one time there was no power) and the lady at the counter, after spending 15 minutes looking at the computer, tells me that I don’t have any more turns left in my Ez 1-2-3 package. I tell them about the whole power outage credit I was suppose to get and she tells me that the computer says that I already got the credit and hence have exhausted the package. I tell her that I have come there only 2 times besides the time they had no power and point to my friend who was in the exact same situation as me and had just gotten his rentals and lift tickets. She says she recognizes me and my friend and believes me but the computer tells her otherwise. I say OK, maybe there has been a glitch or data entry error, can she not override it and give me my last day of the package.

    I mean how big of a deal is it for her to do this when she herself believes that things are okay, even if she didn’t, just the fact that I was there, sincerely arguing my case, should have made her think. Yeah I could’ve been a fool who drove all the way to Snoqualmie to stand in line for an hour and a half to get a free rental but what are the chances? Think woman… think.

    Anyways, that’s where the obtuseness kicks in… all she does is tell me 3 or 4 times that the computer tells her that I have exhausted all days on the package. Each time she tells me that I tell her that I have understood what the problem is but that does not stop her from repeating herself just once more… god I pity her boyfriend or husband.

    Note that this was after a particularly long wait in the lines there. I was dying to get on the slopes and the rental area was clogged with people, and disorganized as usual. I wanted to speak to the manager and she said I would have to go downstairs (to another messy disorganized area in a line with 20 people ahead of me) to speak to her. I went anyway. Tried to get up to the front to explain that I had already been in a line for an hour and half, but all the manager said was that I would have to get in line. I understand their need to have everyone follow the rules but that’s what separates the smart people who get work done from the drones who get everyone in line indiscriminately.

    My friends were on the slopes and I wasn’t going to waste any more time so I went ahead and bought a $180 season’s pass that has rental and lift tickets included, kinda gave in to the mis-management at Snoqualmie. I feel bad about that but they are close to Seattle and easy to get to… really that is the only reason I would go there.

    If I had a choice I wouldn’t, so if you have one, don’t…


  • December 26, 01:38 PM

    Loose Ends

    A few lessons I’ve learnt in life that might make sense to others…

    Tie the loose ends

    There are a bunch of things on your mind; little things that constantly nag you, small hiccups that come up just when you’re starting to have a good time… FIX EM’. I’m not talking about big life changing steps, if you’re gay and your name is Mike Huckabee, you may want to think a little before opening the closet door, but I am taking about waking up an hour early on Sunday morning and making calls to those 5 friends you haven’t touched base with for the last 2 years. And in the meantime, they’ve popped out a couple of kids… or about going to the doc to fix that muscle pull from the snowboarding trip you took…. 4 months ago.

    Figure out what it is, schedule time for it, and go do it. Most of us cannot multitask and the more little loose ends you tie up, you’ll free yourself to make better decisions on the big stuff and have a higher quality of life.

    Be Optimistic

    So you’ve been in the dumps for a while, and you’ve accepted that as a fact of life. You speak in a lower voice, you are risk averse, you’re easily brushed aside… what gives?? Let me give you a hint, it’s not bad fortune. It’s up-to you to stand up and make a difference in your life. So step out of your shell, smile, don’t care too much about other people’s opinion and be optimistic. Really there is no way to tell the cause and effect here, you’re probably in second gear because you don’t wanna make the effort to switch (or get an automatic), not because you wound up with a wilty 2 stroke auto-rickshaw made in India.

    If there is one thing that keeps the world going, it is optimism. Inherently we know that at any point there are 2 options: make things better or worse… i’ll choose better any day.

    Be Kind to Others… and Yourself 

    You cant get 2 people together for a party or a movie, well neither can those 2 people, but that’s not the point. People have personalities that are just as complex (read warped) as yours. Be sensitive to them just as you might expect them to be to yours and give them a break.

    Unwittingly or not, people end up giving off prepackaged vibes about themselves (cool guy, smart guy, corporate girl climbing the ladder… whatever). Call it peer pressure or just conditioning based on their experiences. However, I’ve often found people to be very different from the first impression they give off. And usually better in most cases. The way I look at it is that people have different priorities, different goals, different taboos and different upbringing, and that shapes their day to day behavior and the impressions they leave. Just leave it at that… cause you are no different in that sense.

    Be Enthusiastic

    You always wonder how these huge organizations, sports clubs, dance clubs, hobby clubs etc come about. Comes down to one word… enthusiasm. Some little (or large) prick got enough people excited enough to participate in something and it just took off. There were  a lot of cool people hanging around who are still doing just that… hanging around while that prick went on to enrich their life and the lives of others. And probably made a lot of money doing so. And maaaaaybe got laid too (it’s a stretch though).

    The fact of life is that people are busy and they’re all caught up in their own versions of the same problems that you’re facing. So shed you inhibitions, expose your enthusiasm and go out there participate. You never know what you’re going to find and create. Have fun.


  • December 18, 02:38 AM

    CNN – No Ron Paul

    Dec 16 was the 234th anniversary of the Boston Tea Party. Ron Paul supporters organized a massive fund raiser and raised over $6 million dollars which happens to be a record for a single day for any candidate in the history of the US.

    Huge news you would think.

    Ron Paul is anti-Bush, anti-war, has no special interests to please, a clean and consistent record and is corruption free… not the typical politician such as Giuliani, Romney or Clinton. Without the help of mainstream media and infact without even his own participation, over $6 million dollars have been raised for him. You would think this news is all over the media and he would be given coverage for many hours atleast today, the day he made the record.

    But hell no, CNN is busy covering Pam Anderson’s boobies (or was it her 2 month marriage… they’re fabulous babe but you know what I mean? .  At one point during the afternoon, there was a little link up there but disappeared within the hour.

    MSNBC was slightly better. They had an inconspicuous little link for a long time on the website… but Sanjay was the main attraction of the day… WTF???

    How can I believe that a single honest journalist works in these organizations when there has been no effort to bring forward the most important news of the day or even this entire election so far. The fools in Fox get a memo that tells them what to do but you guys in CNN are self motivated… fucking over-achievers.

     Anyway, maybe it’s all for the better… piss more people off and you might just create the tipping point that lazy Americans need to kick Bush and his cronies along with his followup acts Guiliani and Romney out…

     Here’s Ron Paul’s website: http://www.ronpaul2008.com 

    And here’s a word of wisdom from Kent Snyder, Ron Paul’s campaign chairman

    “Mainstream media is behind the times… maybe 2 or 3 years behind”

    Think about that… it’s before You Tube or Digg were around… damn they’re fuckin’ dinosaurs

    Check him out, donate and spread the word… Peace


  • December 08, 06:51 PM

    No Woman No Cry

    I love this song… and am currently trying to learn the lyrics and play it on the guitar. I first heard it when I was little, many years ago and it always stayed me.  To me it was symbolic of Bob Marley.

    There’s a bunch of people who have performed this song and I was wondering if this really was a Bob Marley original. Turns out that it is though Wikipedia says that it might be a friend of his who actually wrote it. This friend ran a soup kitchen in Trenchtown.  

    “Though Bob Marley likely wrote the song himself, songwriter credits were given to “V. Ford”. Vincent Ford was a friend of Marley’s who ran a soup kitchen in Trenchtown, the ghetto of Kingston, Jamaica where Marley grew up. The royalty cheques received by Ford ensured the survival and continual running of his soup kitchen”

     - From http://en.wikipedia.org/wiki/No_Woman_No_Cry

    In any case, for some reason, this song transports me to my childhood where growing up on sea ports in India (Bombay and Vishakapatnam (Vizag)) my friends and I would find ourselves sitting on deserted naval jetties, watching boats and ship and also sailing little boats in the sea. Really no connection but I think it’s the line “I remember when we used to sit in a government yard in Trenchtown”.

    With all respect to Bob Marley, there’s something about songs like these which makes them bigger than their creators. Another song in this category is “Imagine” by John Lennon.

    One of my favorite renditions of this songs is by Boney M… they just dont make bands like that any more… I love the way Liz Mitchell (I think) swings to the groove of this song… it’s simple and beautiful. Here it is

     and here is the one and only Bob Marley (respect) doin’ it.


  • November 15, 04:14 AM

    Space Needle Lifts

    I live a stone’s throw away from the Seattle Center where the Space Needle is located… and have a beautiful view of it and the EMP (Experience Music Project). Love living here.

    I’ve noticed 2 things and was wondering what the deal is:

    Firstly, the Space Needle lift keeps working all night long. Last night I was sitting around my living room at 2 AM and took a pic. Does anyone know why?

    Secondly, the mono rail that runs from Seattle Cener to Westlake Center keeps running till pretty later too (i’ve seen it at 2 AM). Why?


  • November 04, 12:30 PM

    Why people like Noam Chomsky are not on TV

    No one is better at telling it than he, himself.

    http://www.youtube.com/watch?v=3cceC3DeFcY

    As for Jeff Greenfield, Producer of Nightline, please shut up and dont try to be an intellectual when you are not.


  • October 31, 12:27 PM

    One Smart Economist

    Montek Singh Ahluwalia is one smart guy and has been key in the economic advancement of India. And I like his focus on infrastructure development as key in growth and wealth distribution.

    This is an interview with him in front of Fortune 500 company CEOs

    http://money.cnn.com/video/globalforum/?cnn=yes