Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 2nd, 2003, 09:39 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to call WMI from web service?

Hi,

I have trouble to call WMI from the web service.

The code is like the following:
==================


using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Diagnostics;

using System.Web;

using System.Web.Services;

using System.Text;

using System.Management;

using System.Configuration;



namespace MyWMI

{

    /// <summary>

    /// Summary description for ADSSrv.

    /// </summary>

    ///

    public class MyWMI : System.Web.Services.WebService

    {

        public MyWMI()

        {

            //CODEGEN: This call is required by the ASP.NET Web Services Designer

            InitializeComponent();



        }



        #region Component Designer generated code



        //Required by the Web Services Designer

        private IContainer components = null;



        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

        }



        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        protected override void Dispose( bool disposing )

        {

            if(disposing && components != null)

            {

                components.Dispose();

            }

            base.Dispose(disposing);

        }



        #endregion





        [WebMethod]

        public string MyTest()

        {

            try

            {

                ManagementClass someClass = new ManagementClass("\\\\.\\root\\someclassname");

                ManagementObject objDevice = someClass.CreateInstance();



                // set device properties

                objDevice["Name"] = "sample1.example.com";

                objDevice["Description"] = "Sample device";



                // create device instance

                objDevice.Put();

                return "success";

            }

            catch(Exception ex)

            {

                return ex.ToString();

            }

        }

             }

}




=============================


I run this web service with WMI on the same server with Administrator privilage and I also add user ASPNET to the Administrator group.

But the web service return the following error message:
=======================================
System.Management.ManagemetException:
Access denied at System.Management.ManagementException.ThrowWithExt endedInfo(ManagementStat atus errorCode) System.Management.ManagementObject.Put(PutOptions options) at System.Management.ManagementObject.Put() at MyTest()
========================================


Does anyone know what's wrong with the code?

Thanks,
Reply With Quote
  #2 (permalink)  
Old July 22nd, 2003, 11:58 PM
Authorized User
 
Join Date: Jun 2003
Location: Quezon City, MM, Philippines.
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to planeswalk
Default

Hi,

You can follow the steps below although I am not sure if this is the only thing that needs to get done. If you are logged into the machine where you are trying to use WMI:

1. Go to Programs -> Admin Tools -> Computer Management, then expand the Services and Applications tree node.

2. Right-click WMI Control and click Properties.

3. Go to the Advanced tab and add the ASPNET username with at least Read permissions.

Hope this helps....


Cheers!
Marlon
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web service call error Tomi J2EE 0 February 1st, 2008 06:22 AM
Web Service call fails gurujeet .NET Web Services 10 December 18th, 2006 06:28 PM
call web service from pocket pc rsa3des .NET Web Services 1 June 7th, 2006 07:41 AM
Call a Web Service deer_reema ASP.NET 1.0 and 1.1 Basics 1 April 28th, 2006 10:12 AM
How to call WMI from web service? yezh99 VS.NET 2002/2003 1 July 14th, 2003 10:45 AM



All times are GMT -4. The time now is 08:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.