Problem in debugging a Web Service

Discussion in 'ASP .Net Web Services' started by Sathyaish, Feb 10, 2006.

  1. Sathyaish

    Sathyaish Guest

    I've written a Web Service that has main service class. Let's call the
    main class that exposes the service interface as Service1.

    So, we have:

    public class Service1: System.Web.Services.WebService
    {
    //code
    }


    I also have a business object that I am going to name BusinessObject,
    for example's sake. This object is built in the service module/dll as a
    class like so:


    namespace BusinessObjects
    {
    public class BusinessObject
    {

    private SomeOtherClass mReferenceTypeMember;
    //the field mReferenceTypeMember is exposed through a property
    called ReferenceTypeMember


    //code
    public BusinessObject()
    {
    //nothing for now
    }
    }
    }



    Note that there is only one default ctor for the BusinessObject class
    and that doesn't do anything.

    I compile. Build a DLL. Then I add a test project to this project. I
    add a Web Reference in the Test project to point to the asmx for the
    above-mentioned service. The test project and the service are both a
    part of the same solution. The test project is created to test the
    service.

    In the test project I do,

    //call the default constructor
    TheAliasOfTheWebReference.Service1.BusinessObject bo = new
    TheAliasOfTheWebReference.Service1.BusinessObject();

    bo.ReferenceTypeMember.SomeValueTypeMember = "Value";


    I get an object not set to an instance exception. Reasonable!


    So, I go back to the service asmx.cs file and go straight to the class
    BusinessObject and modify the default constructor to do this:


    namespace BusinessObjects
    {
    public class BusinessObject
    {

    private SomeOtherClass mReferenceTypeMember;
    //the field mReferenceTypeMember is exposed through a property
    called ReferenceTypeMember


    //code
    public BusinessObject()
    {
    this.mRefrenceTypeMember = new SomeOtherClass();
    }
    }
    }



    Then, I rebuild the service.


    I go to the test project. I delete the old Web Reference. I add a new
    Web Reference to the same DLL (I've burnt my fingers there in not
    doing that).

    I insert a breakpoint at the following line

    //call the default constructor
    TheAliasOfTheWebReference.Service1.BusinessObject bo = new
    TheAliasOfTheWebReference.Service1.BusinessObject();


    in the test project.


    I expect it to step through the source code in my service. It doesn't.
    And it still throws the object instance set to nothing exception.



    What gives?
     
    Sathyaish, Feb 10, 2006
    #1
    1. Advertising

  2. Sathyaish

    Martin Kulov Guest

    "Sathyaish" <> wrote in message
    news:...
    > I've written a Web Service that has main service class. Let's call the
    > main class that exposes the service interface as Service1.
    >

    ....
    > I insert a breakpoint at the following line
    >
    > //call the default constructor
    > TheAliasOfTheWebReference.Service1.BusinessObject bo = new
    > TheAliasOfTheWebReference.Service1.BusinessObject();
    >
    >
    > in the test project.
    >
    >
    > I expect it to step through the source code in my service. It doesn't.
    > And it still throws the object instance set to nothing exception.
    >
    >


    Hi Sathyaish,
    The reason that you have object not set to instance exception is that the
    object on the client side does not instantiate the same constructor that you
    have defined at the service. The definition of your class goes to the client
    only by the means of WSDL description. Hence no methods or code are
    delivered to the client side. That makes pretty much sense since the goal of
    web services is to provide interoperable way for communication. After all
    there is no way to execute C# code on JVM. You need to have common
    initialization class available to both projects, if you want to reuse the
    code.

    Regards,

    --
    Martin Kulov
    http://www.codeattest.com/blogs/martin

    MCAD Charter Member
    MCSD.NET Early Achiever
    MCSD
     
    Martin Kulov, Feb 14, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hocho888
    Replies:
    1
    Views:
    687
  2. dgleeson422111

    Consuming local web service - ok, remote web service -problem?

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    932
    dgleeson422111
    Jan 26, 2010
  3. Scott Baierl
    Replies:
    1
    Views:
    304
    Scott Baierl
    Jul 29, 2006
  4. Leo Violette
    Replies:
    0
    Views:
    1,108
    Leo Violette
    Apr 17, 2009
  5. Redhot
    Replies:
    0
    Views:
    785
    Redhot
    Jul 18, 2009
Loading...

Share This Page