Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Calling COM+ in a WebService

Reply
Thread Tools

Calling COM+ in a WebService

 
 
Daryl Davis
Guest
Posts: n/a
 
      06-11-2004
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


 
Reply With Quote
 
 
 
 
Daryl Davis
Guest
Posts: n/a
 
      06-11-2004
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)"
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed). ..
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/de...ntTutorial.asp

--
Stuart
See headers for PGP Key.
He who laughs last thinks slowest!


 
Reply With Quote
 
 
 
 
Daryl Davis
Guest
Posts: n/a
 
      06-14-2004
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)"
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
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.


 
Reply With Quote
 
Daryl Davis
Guest
Posts: n/a
 
      06-16-2004
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)"
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem! webservice.htc calling nonsecure webservice from a secured ssl https webpage batista ASP .Net 1 01-26-2006 12:05 PM
Problem! webservice.htc calling nonsecure webservice from a secured ssl https webpage batista ASP .Net Web Services 0 01-26-2006 08:14 AM
Problem! webservice.htc calling nonsecure webservice from a secured ssl https webpage batista ASP .Net 0 01-26-2006 08:13 AM
Calling a webservice from a webservice bgauvey@gmail.com ASP .Net Web Services 2 04-20-2005 02:02 PM
Webservice calling a webservice.....Error Peter Nordström ASP .Net Web Services 0 10-21-2003 12:02 PM



Advertisments