Calling COM+ in a WebService

Discussion in 'ASP .Net Web Services' started by Daryl Davis, Jun 11, 2004.

  1. Daryl Davis

    Daryl Davis Guest

    Can I get a sample on how to call a com+ componant in a webservice, please?
    This is what I have so far and I am getting an error
    Run-time exception thrown : System.NullReferenceException - Object reference
    not set to an instance of an object.

    Imports System.Web.Services

    Imports System.Runtime.InteropServices

    <WebMethod()> _

    Public Function GetRegKey() As String

    Dim obj As Object

    obj = CreateObject("hallconfigs.clsconfigs", "192.168.10.1")

    Return obj.GetRegKey

    End Function
     
    Daryl Davis, Jun 11, 2004
    #1
    1. Advertising

  2. Daryl Davis

    Daryl Davis Guest

    Ok, so your as blunt as a rusty sword, go for a tree trunk.
    I am searching through the msdn and I am unable to figure out (might just be
    early) how to get this to work with a server components.
    Daryl

    "Stuart Hemming (via DFN-CIS NetNews Service)"
    <> wrote in message
    news:...
    On 11/06/2004, around 08:55, Daryl Davis wrote:

    DD> Can I get a sample on how to call a com+ componant in a webservice,
    please?
    Forgive me if I sound blunt, but you're doing it wrong. If you have
    MSDN on you machine go to Visual Studio .Net|Visual Basic and Visual
    C#|Programming with Components|COM Interoperability. Failing that,
    there's a tutorial starting at the page pointed to on the link below.

    http://msdn.microsoft.com/library/d.../html/vcwlkCOMInteropPart1CClientTutorial.asp

    --
    Stuart
    See headers for PGP Key.
    He who laughs last thinks slowest!
     
    Daryl Davis, Jun 11, 2004
    #2
    1. Advertising

  3. Daryl Davis

    Daryl Davis Guest

    I wish it did. I can call Dlls fine, except from a WebService...
    I tried imitating your code and that did not help me either.
    Daryl
    "Stuart Hemming (via DFN-CIS NetNews Service)"
    <> wrote in message
    news:...
    On 11/06/2004, around 13:36, Daryl Davis wrote:

    DD> Ok, so your as blunt as a rusty sword, go for a tree trunk.
    DD> I am searching through the msdn and I am unable to figure out (might
    just be
    DD> early) how to get this to work with a server components.
    FWIW, here's what I did.

    I'm developing on a machine that has the server components on it so
    YMMV.

    In you VS project right click on 'References' on the project explorer
    and select 'Add Reference'. When the dialog box opens, select the
    'COM' tab and pick the COM server you're after. Click 'OK'. When the
    machine has finished clicking and wrrring you should have a reference
    named for your COM server.

    Add a 'using' clause you get the thing recognised in your code and
    you're away. Here's a simple example of my code accessing a COM server
    called ECS ...

    public XmlDocument InputValidation(XmlDocument ChangedValues) {
    XmlDocument xmlDoc = new XmlDocument();
    Ecs.EcsApplicationClass thisEcs;

    thisEcs.Define("ecs-process", "input-validation");
    thisEcs.InputText = ChangedValues.OuterXml;
    thisEcs.RunProcess();

    if (thisEcs.OutputText != null && thisEcs.OutputText != "") {
    xmlDoc.LoadXml(thisEcs.OutputText);
    // ...
    }
    return xmlDoc;
    }
    public void Logout() {
    Ecs.EcsApplicationClass thisEcs;
    if (Session["ecs"] != null) {
    thisEcs = (Ecs.EcsApplicationClass)Session["ecs"];
    Marshal.ReleaseComObject(thisEcs);
    Session.Clear();
    }
    }

    EcsApplicationClass is the constructor if you like, Define, and
    RunProcess are methods, InputText and OutputText are properties. Not
    that in Logout you have to call Marshal.ReleaseComObject else the
    object remains on the server.

    I hope this helps.

    --
    Stuart
    See headers for PGP Key.
    Once, in the Congo, I lost my corkscrew, and was forced to live on
    nothing but food and water for days.
     
    Daryl Davis, Jun 14, 2004
    #3
  4. Daryl Davis

    Daryl Davis Guest

    You want info, Ill give you info :), Although at this point I am wondering
    if it is a bug, because everything I read says this is the way it works.

    The com object is a V6 dll sitting on a server. This dll is used to access
    SQL database located on the same server.

    here is my code on my webservice
    <WebMethod()> _

    Public Function GetRegKey() As String

    Dim obj1 As hallconfigs.clsConfigs

    Try

    obj1 = CreateObject("hallconfigs.clsconfigs", "192.168.10.254")

    Return obj1.GetRegKey 'returns a simple string

    Catch ex As Exception

    Return 0

    End Try

    End Function

    "Stuart Hemming (via DFN-CIS NetNews Service)"
    <> wrote in message
    news:...
    On 14/06/2004, around 09:10, Daryl Davis wrote:

    DD> I wish it did. I can call Dlls fine, except from a WebService...
    DD> I tried imitating your code and that did not help me either.

    You're gonna have to give me some more info.

    For example, what's the COM object?
    --
    Stuart
    See headers for PGP Key.
    A bicycle can't stand on its own because it is two-tired.
     
    Daryl Davis, Jun 16, 2004
    #4
    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. batista
    Replies:
    1
    Views:
    932
    Laurent Bugnion
    Jan 26, 2006
  2. batista
    Replies:
    0
    Views:
    572
    batista
    Jan 26, 2006
  3. Peter Nordström

    Webservice calling a webservice.....Error

    Peter Nordström, Oct 21, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    176
    Peter Nordström
    Oct 21, 2003
  4. Calling a webservice from a webservice

    , Apr 19, 2005, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    162
  5. batista
    Replies:
    0
    Views:
    261
    batista
    Jan 26, 2006
Loading...

Share This Page