summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnas Nashif <nashif@intel.com>2007-03-06 04:47:47 +0000
committerAnas Nashif <nashif@intel.com>2007-03-06 04:47:47 +0000
commit13fade8b52431d7bef6930556d0760f45df2386c (patch)
tree8ad782f0107da2b184aca628d97e7358d67946d5
parentf5d6e2a8e47e09f01413b9a1499cdbb69873b924 (diff)
-rw-r--r--configure.in2
-rw-r--r--examples/Makefile.am5
-rw-r--r--examples/README83
-rw-r--r--examples/new_api_example.c2
-rw-r--r--examples/new_api_transfer_create.c116
-rw-r--r--examples/serialize.c133
-rw-r--r--examples/win32_service.c420
-rw-r--r--examples/wsmid_identify.c5
-rw-r--r--src/wsman.c2
9 files changed, 418 insertions, 350 deletions
diff --git a/configure.in b/configure.in
index b41db01..6c33b84 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(wsmancli, 0.7.0)
+AC_INIT(wsmancli, 0.7.2)
AC_CONFIG_SRCDIR(wsmancli.spec.in)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c81af3b..f34d31a 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -23,6 +23,8 @@ create_resource_SOURCES = \
new_api_example_SOURCES = \
new_api_example.c
+new_api_transfer_create_SOURCES = \
+ new_api_transfer_create.c
noinst_PROGRAMS = \
wsmid_identify \
@@ -30,7 +32,8 @@ noinst_PROGRAMS = \
enum_epr \
create_resource \
serialize \
- new_api_example
+ new_api_example \
+ new_api_transfer_create
diff --git a/examples/README b/examples/README
new file mode 100644
index 0000000..e1144c6
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,83 @@
+
+wsmid_identify
+--------------
+
+Summary:
+ Issue an Identify request and de-serialize the result.
+Options:
+ -p, --product Print Product Vendor
+ -v, --version Print Product Version
+ -P, --protocol Print Protocol Version
+ -u, --endpoint=<uri> Endpoint in form of a URL
+Example:
+
+ % ./wsmid_identify -u http://wsman:secret@example.com:8889/wsman
+
+ Openwsman Project 0.7.0 supporting protocol http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
+
+
+serialize
+----------
+
+Summary:
+ Examples using the XML serialization and de-serialization API.
+Options:
+ None
+Example:
+ run ./serialize in the local directory which will do several serialization and
+ de-serialization routines.
+ For more details, check the file 'doc/README.serialization' in the openwsman
+ repository for detailed documentation of the serialization API.
+
+
+win32_service
+----------------
+Summary:
+ A command-line client to manage and display services on a Microsoft Windows machine
+ with WS-Management support (Vista).
+Options:
+ -u, --endpoint=<uri> Endpoint in form of a URL
+ -l, --list-all List all services
+ -d, --desc Show service description
+ -s, --stop Stop service
+ -S, --start Start service
+ -X, --status Get service status
+ -D, --dump Dump request
+
+ For actions related to one service, add the name of the service as an argument.
+
+Example:
+
+ ./win32_service -u http://wsman:secret@example.com:80/wsman -l -X
+ ...
+ ...
+ wmiApSrv
+ State: Stopped
+ WMPNetworkSvc
+ State: Stopped
+ WPCSvc
+ State: Stopped
+ WPDBusEnum
+ State: Running
+ wscsvc
+ State: Running
+ WSearch
+ State: Running
+ wuauserv
+ State: Running
+ wudfsvc
+ State: Stopped
+ ...
+ ...
+
+
+ ./win32_service -u http://wsman:secret@example.com:80/wsman -d wudfsvc
+
+ wudfsvc
+ State: Stopped
+ Description: Manages user-mode driver host processes
+
+
+
+
+
diff --git a/examples/new_api_example.c b/examples/new_api_example.c
index e882fcc..bae55f6 100644
--- a/examples/new_api_example.c
+++ b/examples/new_api_example.c
@@ -1,7 +1,5 @@
#include "wsman-client-api.h"
-static char *endpoint = NULL;
-
int main(int argc, char** argv)
{
int sid;
diff --git a/examples/new_api_transfer_create.c b/examples/new_api_transfer_create.c
new file mode 100644
index 0000000..185fad4
--- /dev/null
+++ b/examples/new_api_transfer_create.c
@@ -0,0 +1,116 @@
+#include "wsman-client-api.h"
+#include "wsman-xml-serializer.h"
+
+#define CLASSNAME "EXL_ExamplePolicy"
+
+SER_TYPEINFO_UINT32;
+
+struct __EXL_ExamplePolicy
+{
+ XML_TYPE_STR ElementName;
+ XML_TYPE_STR Description;
+ XML_TYPE_STR Caption;
+ XML_TYPE_STR InstanceID;
+ XML_TYPE_STR PolicyName;
+ XML_TYPE_UINT32 PolicyPrecedence;
+ XML_TYPE_DYN_ARRAY Handles;
+ XML_TYPE_BOOL DefaultTest;
+
+};
+typedef struct __EXL_ExamplePolicy EXL_ExamplePolicy;
+
+SER_START_ITEMS(EXL_ExamplePolicy)
+SER_STR("ElementName", 1),
+SER_STR("Description", 1),
+SER_STR("Caption", 1),
+SER_STR("InstanceID", 1),
+SER_STR("PolicyName", 1),
+SER_UINT32("PolicyPrecedence", 1 ),
+SER_DYN_ARRAY("Handles", 1, 10, uint32),
+SER_BOOL("DefaultTest", 1),
+SER_END_ITEMS(EXL_ExamplePolicy);
+
+int main(int argc, char** argv)
+{
+ int sid;
+ int i = 0;
+ char *res;
+ const char *resource_uri =
+ "http://example.com/wbem/wscim/1/schema/1/EXL_ExamplePolicy";
+ int retval;
+ u_error_t *error = NULL;
+ char *user = NULL;
+ char *passwd = NULL;
+
+ u_option_entry_t opt[] = {
+ { "user", 'u', U_OPTION_ARG_STRING, &user,
+ "user name", "<user>" },
+ { "passwd", 'p', U_OPTION_ARG_STRING, &passwd,
+ "password", "<passwd>" },
+ { NULL }
+ };
+
+
+ u_option_context_t *opt_ctx;
+ opt_ctx = u_option_context_new("");
+ u_option_context_set_ignore_unknown_options(opt_ctx, FALSE);
+ u_option_context_add_main_entries(opt_ctx, opt, "adv api example");
+ retval = u_option_context_parse(opt_ctx, &argc, &argv, &error);
+ u_option_context_free(opt_ctx);
+
+ if (error) {
+ if (error->message)
+ printf ("%s\n", error->message);
+ u_error_free(error);
+ return 1;
+ }
+ u_error_free(error);
+
+ if (!user || !passwd) {
+ printf("\t new_api_example: user and passwd are required\n");
+ return 1;
+ }
+
+ sid = wsman_session_open("localhost", 8889, "/wsman", "http",
+ user, passwd, 0);
+
+ if (sid < 0) {
+ printf("Open session failed\n");
+ return 0;
+ }
+ wsman_session_resource_locator_set(sid, resource_uri);
+
+ EXL_ExamplePolicy *d = u_malloc(sizeof(EXL_ExamplePolicy));
+ d->ElementName = u_strdup("name");
+ d->DefaultTest = 1;
+
+ int *array = NULL;
+ int count = 4;
+ array = (int *) malloc (sizeof (int) * count);
+ array[0] = 1;
+ array[1] = 0;
+ array[2] = 3;
+ array[3] = 5;
+ d->Handles.count = count;
+ d->Handles.data = array;
+
+ printf("\n******** Opened session id %d ********\n\n", sid);
+
+ res = wsman_session_serialize(sid, d, EXL_ExamplePolicy_TypeInfo);
+printf("%s\n", res);
+ res = wsman_session_transfer_create(sid, res, 0);
+
+ if (!res) {
+ printf("******** Transfer Create failed - %s ********\n\n",
+ wsman_session_error(sid));
+ return 0;
+ }
+
+ printf ("******** Transfer Create response ********\n%s\n", res);
+
+ wsman_session_close(sid);
+
+ printf("******** Closed session id %d ********\n\n", sid);
+
+ return 1;
+}
diff --git a/examples/serialize.c b/examples/serialize.c
index 5cb6172..fed4743 100644
--- a/examples/serialize.c
+++ b/examples/serialize.c
@@ -48,139 +48,6 @@
#define CLASSNAME "Sample"
-/*
- ************************************************************************
-
- HOW TO USE SERIALIZATION / DESERIALIZATION
-
- Serialization/deserialization of unsignedByte, unsignedShort,
- unsignedInt, boolean and string built-n XML Schema types is now supported.
- It is possible to serialize/deserialize structures, static and dynamic
- size arrays constructed from these types.
-
- For example, let us have the following schema:
- <xsd:element name="SAMPLE">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="STRING" type="xsd:string"/>
- <xsd:element name="BOOL" type="xsd:boolean"/>
- <xsd:element name="BYTE" type="xsd:unsignedByte"/>
- <xsd:element name="SHORT" type="xsd:unsignedShort"/>
- <xsd:element name="INT" type="xsd:unsignedInt"/>
- <xsd:element name="SHORTS" type="xsd:unsignedShort" minOccurs="3" maxOccurs="3"/>
- <xsd:element name="INTS" type="xsd:unsignedInt" minOccurs="0" maxOccurs="5"/>
- <xsd:element ref="FOO" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="FOO">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="FooSTRING" type="xsd:string"/>
- <xsd:element name="FooINT" type="xsd:unsignedInt"/>
- <xsd:element name="FooBOOL" type="xsd:boolean"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
-
- Each complex element is represented in the C programm by 2 objects - target
- structure (TS) definition and type description object (TDO) - the null
- terminated array of type XmlSerializerInfo elements. The following name
- convention exists: TDO for Foo is named Foo_TypeInfo.
- For our example these structures look the following:
-
- target structures:
-
- typedef struct {
- XML_TYPE_STR FooString;
- XML_TYPE_UINT32 FooInt;
- XML_TYPE_BOOL FooBoolean;
- } Foo;
-
- typedef struct {
- XML_TYPE_STR String;
- XML_TYPE_BOOL Boolean;
- XML_TYPE_UINT8 Byte;
- XML_TYPE_UINT16 Short;
- XML_TYPE_UINT32 Int;
- XML_TYPE_UINT16 Shorts[3];
- XML_TYPE_DYN_ARRAY Ints;
- XML_TYPE_DYN_ARRAY Foos;
- } Sample;
-
- Note, that the field 'Shorts' in Sample is defined as built-in array because
- the number of elements in schema is strictly defined. Elements Ints
- and Foos are defined as dynamic arrays because the number of these elements
- in the document is variable.
-
- For each TS an TDO is defined. Each TDS is defined by the sequence of
- defines described in wsman-xml-serializer.h. The order of defines in TDO
- must be same as the order of fields in TS.
-
- SER_START_ITEMS("FOO", Foo)
- // This is the beginning of the description. The first argument is the
- // name of an element in the XML schema, the second one is the name
- // of the TS type.
- SER_STR("FooSTRING", 1),
- SER_UINT32("FooINT", 1),
- SER_BOOL("FooBOOL", 1),
- // These 3 defines are for string, unsignedInt and boolean XML types
- // accordingly. The first argument is the name of an element in the XML
- // schema, the second one is the number of elements.
- SER_END_ITEMS("FOO", Foo);
- // This Define completes the definition. The arguments are same as
- // for SER_START_ITEMS.
-
- So if we define The TDO for Foo type. It looks like:
- XmlSerializerInfo Foo_TypeInfo[] = {
- ................
- };
- There are some Defines to add XmlSerializerInfo's for basic types XML_TYPE_UINT8,
- XML_TYPE_UINT16, XML_TYPE_UINT32, XML_TYPE_BOOL and XML_TYPE_STR:
- SER_TYPEINFO_UINT8;
- SER_TYPEINFO_UINT16;
- SER_TYPEINFO_UINT32;
- SER_TYPEINFO_BOOL;
- SER_TYPEINFO_STR;
- If you use dymanic arrays of basic types you must define the corespondent
- XmlSerializerInfo before defining TDO including this dynamic array. You will
- refer to these TDOs in SER_DYN_ARRAY define and use the fourth argument for
- these types uint8, uint16, uint32, bool and string as the last argument (see
- below).
-
- Let's do the same for the Sample type.
-
- SER_START_ITEMS(sample)
- SER_STR("STRING", 1),
- SER_BOOL("BOOL", 1),
- SER_UINT8("BYTE", 1),
- SER_UINT16("SHORT", 1),
- SER_UINT32("INT", 1),
- SER_UINT16("SHORTS", 3),
- SER_DYN_ARRAY("INTS", 0, 5, uint32),
- // This dynamic array describes XML element INTS of type unsignedInt
- // with minOccurs=0 and maxOccurs=5.
- SER_DYN_ARRAY("FOOS", 1, 0, Foo),
- // Dynamic array of Foo type elements. maxOccures=0 means
- // "unbounded" in XML schema
- SER_END_ITEMS(sample);
-
-
- These objects can be used in ws_serialize() and ws_deserialize() API.
-
- There are 2 sets of defines SER_IN_* and SER_OUT_*. These defines are used
- if you want to skip the elements while deserialization(serialization). If
- define SER_INOUT_* is used the element is skipped always.
-
- If element name is a QName (with name space prefix) the
- SER_NS_*(ns, name, ..) define set must be used.
-
-
-
- *****************************************************************/
-
-
static void
diff --git a/examples/win32_service.c b/examples/win32_service.c
index 791b1c5..6bbf491 100644
--- a/examples/win32_service.c
+++ b/examples/win32_service.c
@@ -38,101 +38,98 @@
#include <errno.h>
#include <time.h>
-#include "u/libu.h"
-#include "wsman-client-api.h"
-#include "wsman-client-transport.h"
-#include "wsman-xml-serializer.h"
+#include "wsman-api.h"
#define RESOURCE_URI "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service"
#define CLASSNAME "Win32_Service"
/*
- boolean AcceptPause;
- boolean AcceptStop;
- string Caption;
- uint32 CheckPoint;
- string CreationClassName;
- string Description;
- boolean DesktopInteract;
- string DisplayName;
- string ErrorControl;
- uint32 ExitCode;
- datetime InstallDate;
- string Name;
- string PathName;
- uint32 ProcessId;
- uint32 ServiceSpecificExitCode;
- string ServiceType;
- boolean Started;
- string StartMode;
- string StartName;
- string State;
- string Status;
- string SystemCreationClassName;
- string SystemName;
- uint32 TagId;
- uint32 WaitHint;
-
- */
+ boolean AcceptPause;
+ boolean AcceptStop;
+ string Caption;
+ uint32 CheckPoint;
+ string CreationClassName;
+ string Description;
+ boolean DesktopInteract;
+ string DisplayName;
+ string ErrorControl;
+ uint32 ExitCode;
+ datetime InstallDate;
+ string Name;
+ string PathName;
+ uint32 ProcessId;
+ uint32 ServiceSpecificExitCode;
+ string ServiceType;
+ boolean Started;
+ string StartMode;
+ string StartName;
+ string State;
+ string Status;
+ string SystemCreationClassName;
+ string SystemName;
+ uint32 TagId;
+ uint32 WaitHint;
+
+*/
struct __CIM_Servie
{
- XML_TYPE_BOOL AcceptPause;
- XML_TYPE_BOOL AcceptStop;
- XML_TYPE_STR Caption;
- XML_TYPE_UINT32 CheckPoint;
- XML_TYPE_STR CreationClassName;
- XML_TYPE_STR Description;
- XML_TYPE_BOOL DesktopInteract;
- XML_TYPE_STR DisplayName;
- XML_TYPE_STR ErrorControl;
- XML_TYPE_UINT32 ExitCode;
- XML_TYPE_STR InstallDate;
- XML_TYPE_STR Name;
- XML_TYPE_STR PathName;
- XML_TYPE_UINT32 ProcessId;
- XML_TYPE_UINT32 ServiceSpecificExitCode;
- XML_TYPE_STR ServiceType;
- XML_TYPE_BOOL Started;
- XML_TYPE_STR StartMode;
- XML_TYPE_STR StartName;
- XML_TYPE_STR State;
- XML_TYPE_STR Status;
- XML_TYPE_STR SystemCreationClassName;
- XML_TYPE_STR SystemName;
- XML_TYPE_UINT32 TagId;
- XML_TYPE_UINT32 WaitHint;
+ XML_TYPE_BOOL AcceptPause;
+ XML_TYPE_BOOL AcceptStop;
+ XML_TYPE_STR Caption;
+ XML_TYPE_UINT32 CheckPoint;
+ XML_TYPE_STR CreationClassName;
+ XML_TYPE_STR Description;
+ XML_TYPE_BOOL DesktopInteract;
+ XML_TYPE_STR DisplayName;
+ XML_TYPE_STR ErrorControl;
+ XML_TYPE_UINT32 ExitCode;
+ XML_TYPE_STR InstallDate;
+ XML_TYPE_STR Name;
+ XML_TYPE_STR PathName;
+ XML_TYPE_UINT32 ProcessId;
+ XML_TYPE_UINT32 ServiceSpecificExitCode;
+ XML_TYPE_STR ServiceType;
+ XML_TYPE_BOOL Started;
+ XML_TYPE_STR StartMode;
+ XML_TYPE_STR StartName;
+ XML_TYPE_STR State;
+ XML_TYPE_STR Status;
+ XML_TYPE_STR SystemCreationClassName;
+ XML_TYPE_STR SystemName;
+ XML_TYPE_UINT32 TagId;
+ XML_TYPE_UINT32 WaitHint;
};
typedef struct __CIM_Servie CIM_Servie;
SER_START_ITEMS(CIM_Servie)
-SER_BOOL("AcceptPause", 1),
-SER_BOOL("AcceptStop", 1),
-SER_STR("Caption", 1),
-SER_UINT32("CheckPoint", 1),
-SER_STR("CreationClassName", 1),
-SER_STR("Description", 1),
-SER_BOOL("DesktopInteract", 1),
-SER_STR("DisplayName", 1),
-SER_STR("ErrorControl", 1),
-SER_UINT32("ExitCode", 1),
-SER_STR("InstallDate", 1),
-SER_STR("Name", 1),
-SER_STR("PathName", 1),
-SER_UINT32("ProcessId", 1),
-SER_UINT32("ServiceSpecificExitCode", 1),
-SER_STR("ServiceType", 1),
-SER_BOOL("Started", 1),
-SER_STR("StartMode", 1),
-SER_STR("StartName", 1),
-SER_STR("State", 1),
-SER_STR("Status", 1),
-SER_STR("SystemCreationClassName", 1),
-SER_STR("SystemName", 1),
-SER_UINT32("TagId", 1),
-SER_UINT32("WaitHint", 1),
+SER_NS_BOOL(RESOURCE_URI,"AcceptPause", 1),
+SER_NS_BOOL(RESOURCE_URI,"AcceptStop", 1),
+SER_NS_STR(RESOURCE_URI,"Caption", 1),
+SER_NS_UINT32(RESOURCE_URI,"CheckPoint", 1),
+SER_NS_STR(RESOURCE_URI,"CreationClassName", 1),
+SER_NS_STR(RESOURCE_URI,"Description", 1),
+SER_NS_BOOL(RESOURCE_URI,"DesktopInteract", 1),
+SER_NS_STR(RESOURCE_URI,"DisplayName", 1),
+SER_NS_STR(RESOURCE_URI,"ErrorControl", 1),
+SER_NS_UINT32(RESOURCE_URI,"ExitCode", 1),
+SER_NS_STR(RESOURCE_URI,"InstallDate", 1),
+SER_NS_STR(RESOURCE_URI,"Name", 1),
+SER_NS_STR(RESOURCE_URI,"PathName", 1),
+SER_NS_UINT32(RESOURCE_URI,"ProcessId", 1),
+SER_NS_UINT32(RESOURCE_URI,"ServiceSpecificExitCode", 1),
+SER_NS_STR(RESOURCE_URI,"ServiceType", 1),
+SER_NS_BOOL(RESOURCE_URI,"Started", 1),
+SER_NS_STR(RESOURCE_URI,"StartMode", 1),
+SER_NS_STR(RESOURCE_URI,"StartName", 1),
+SER_NS_STR(RESOURCE_URI,"State", 1),
+SER_NS_STR(RESOURCE_URI,"Status", 1),
+SER_NS_STR(RESOURCE_URI,"SystemCreationClassName", 1),
+SER_NS_STR(RESOURCE_URI,"SystemName", 1),
+SER_NS_UINT32(RESOURCE_URI,"TagId", 1),
+SER_NS_UINT32(RESOURCE_URI,"WaitHint", 1),
SER_END_ITEMS(CIM_Servie);
static char *endpoint = NULL;
@@ -146,143 +143,150 @@ char dump = 0;
-static void print_info(CIM_Servie *service) {
- printf("%s\n", service->Name );
- if (status)
- printf("\tState: %s\n", service->State );
- if (desc)
- printf("\tDescription: %s\n\n", service->Description );
+static void print_info(CIM_Servie *service)
+{
+ if (service->Name) {
+ printf("%s\n", service->Name );
+ } else {
+ printf("Error\n");
+ return;
+ }
+ if (status)
+ printf("\tState: %s\n", service->State );
+ if (desc)
+ printf("\tDescription: %s\n\n", service->Description );
}
static int list_services(WsManClient *cl, WsXmlDocH doc, void *data)
{
-
- if (doc) {
- WsXmlNodeH node = ws_xml_get_soap_body(doc);
- node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_PULL_RESP);
- node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_ITEMS);
- if (ws_xml_get_child(node, 0, RESOURCE_URI , CLASSNAME )) {
- CIM_Servie *service = ws_deserialize(wsman_client_get_context(cl),
- node,
- CIM_Servie_TypeInfo, CLASSNAME,
- RESOURCE_URI, NULL,
- 0, 0);
- print_info(service);
- }
- }
+ if (!doc) {
+ return;
+ }
+ if (dump)
+ ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
+ WsXmlNodeH node = ws_xml_get_soap_body(doc);
+ node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_PULL_RESP);
+ node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_ITEMS);
+ if (ws_xml_get_child(node, 0, RESOURCE_URI , CLASSNAME )) {
+ CIM_Servie *service = ws_deserialize(wsman_client_get_context(cl),
+ node,
+ CIM_Servie_TypeInfo, CLASSNAME,
+ RESOURCE_URI, NULL,
+ 0, 0);
+ print_info(service);
+ }
}
int main(int argc, char** argv)
{
-
- WsManClient *cl;
- WsXmlDocH doc;
- actionOptions options;
- char retval = 0;
- u_error_t *error = NULL;
-
-
- u_option_entry_t opt[] = {
- { "endpoint", 'u', U_OPTION_ARG_STRING, &endpoint,
- "Endpoint in form of a URL", "<uri>" },
- { "list-all", 'l', U_OPTION_ARG_NONE, &listall,
- "List all services", NULL },
- { "desc", 'd', U_OPTION_ARG_NONE, &desc,
- "Show service description", NULL },
- { "stop", 's', U_OPTION_ARG_NONE, &stop,
- "Stop service", NULL },
- { "start", 'S', U_OPTION_ARG_NONE, &start,
- "Start service", NULL },
- { "status", 'X', U_OPTION_ARG_NONE, &status,
- "Get service status", NULL },
- { "dump", 'D', U_OPTION_ARG_NONE, &dump,
- "Dump request", NULL },
- { NULL }
- };
-
- u_option_context_t *opt_ctx;
- opt_ctx = u_option_context_new("");
- u_option_context_set_ignore_unknown_options(opt_ctx, FALSE);
- u_option_context_add_main_entries(opt_ctx, opt, "Win32 Service");
- retval = u_option_context_parse(opt_ctx, &argc, &argv, &error);
-
- u_option_context_free(opt_ctx);
-
- if (error) {
- if (error->message)
- printf ("%s\n", error->message);
- u_error_free(error);
- return 1;
- }
- u_error_free(error);
-
-
- u_uri_t *uri;
- if (endpoint) {
- u_uri_parse((const char *)endpoint, &uri);
- }
- if (!endpoint || !uri) {
- fprintf(stderr, "endpoint option required\n");
- return 1;
- }
-
-
- wsman_client_transport_init(NULL);
- cl = wsman_create_client( uri->host,
- uri->port,
- uri->path,
- uri->scheme,
- uri->user,
- uri->pwd);
- initialize_action_options(&options);
-
- if (listall) {
- wsenum_enumerate_and_pull(cl, RESOURCE_URI, options, list_services, NULL );
-
- } else if (start && argv[1]) {
- if (dump) wsman_set_action_option(&options,FLAG_DUMP_REQUEST );
- wsman_client_add_selector(&options, "Name", argv[1]);
- doc = wsman_invoke(cl, RESOURCE_URI, options,
- "StartService", NULL);
- ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
- ws_xml_destroy_doc(doc);
- } else if (stop && argv[1]) {
- if (dump) wsman_set_action_option(&options,FLAG_DUMP_REQUEST );
- wsman_client_add_selector(&options, "Name", argv[1]);
- doc = wsman_invoke(cl, RESOURCE_URI, options,
- "StopService", NULL);
- ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
- ws_xml_destroy_doc(doc);
- } else if ( argv[1] ) {
- if (dump) wsman_set_action_option(&options,FLAG_DUMP_REQUEST );
- wsman_client_add_selector(&options, "Name", argv[1]);
- doc = ws_transfer_get(cl, RESOURCE_URI,
- options);
- if (doc) {
- WsXmlNodeH node = ws_xml_get_soap_body(doc);
- if (ws_xml_get_child(node, 0, RESOURCE_URI , CLASSNAME )) {
- CIM_Servie *service = ws_deserialize(wsman_client_get_context(cl),
- node,
- CIM_Servie_TypeInfo, CLASSNAME,
- RESOURCE_URI, NULL,
- 0, 0);
- desc = 1;
- status = 1;
- print_info(service);
- }
- }
- ws_xml_destroy_doc(doc);
- }
-
- if (uri) {
- u_uri_free(uri);
- }
-
- destroy_action_options(&options);
- wsman_release_client(cl);
- return 0;
+ WsManClient *cl;
+ WsXmlDocH doc;
+ actionOptions options;
+ char retval = 0;
+ u_error_t *error = NULL;
+
+
+ u_option_entry_t opt[] = {
+ { "endpoint", 'u', U_OPTION_ARG_STRING, &endpoint,
+ "Endpoint in form of a URL", "<uri>" },
+ { "list-all", 'l', U_OPTION_ARG_NONE, &listall,
+ "List all services", NULL },
+ { "desc", 'd', U_OPTION_ARG_NONE, &desc,
+ "Show service description", NULL },
+ { "stop", 's', U_OPTION_ARG_NONE, &stop,
+ "Stop service", NULL },
+ { "start", 'S', U_OPTION_ARG_NONE, &start,
+ "Start service", NULL },
+ { "status", 'X', U_OPTION_ARG_NONE, &status,
+ "Get service status", NULL },
+ { "dump", 'D', U_OPTION_ARG_NONE, &dump,
+ "Dump request", NULL },
+ { NULL }
+ };
+
+ u_option_context_t *opt_ctx;
+ opt_ctx = u_option_context_new("");
+ u_option_context_set_ignore_unknown_options(opt_ctx, FALSE);
+ u_option_context_add_main_entries(opt_ctx, opt, "Win32 Service");
+ retval = u_option_context_parse(opt_ctx, &argc, &argv, &error);
+
+ u_option_context_free(opt_ctx);
+
+ if (error) {
+ if (error->message)
+ printf ("%s\n", error->message);
+ u_error_free(error);
+ return 1;
+ }
+ u_error_free(error);
+
+
+ u_uri_t *uri;
+ if (endpoint) {
+ u_uri_parse((const char *)endpoint, &uri);
+ }
+ if (!endpoint || !uri) {
+ fprintf(stderr, "endpoint option required\n");
+ return 1;
+ }
+
+
+ wsman_client_transport_init(NULL);
+ cl = wsman_create_client( uri->host,
+ uri->port,
+ uri->path,
+ uri->scheme,
+ uri->user,
+ uri->pwd);
+ initialize_action_options(&options);
+
+ if (listall) {
+ if (dump) wsman_set_action_option(&options,FLAG_DUMP_REQUEST );
+ wsenum_enumerate_and_pull(cl, RESOURCE_URI, options, list_services, NULL );
+ } else if (start && argv[1]) {
+ if (dump) wsman_set_action_option(&options,FLAG_DUMP_REQUEST );
+ wsman_client_add_selector(&options, "Name", argv[1]);
+ doc = wsman_invoke(cl, RESOURCE_URI, options,
+ "StartService", NULL);
+ ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
+ ws_xml_destroy_doc(doc);
+ } else if (stop && argv[1]) {
+ if (dump) wsman_set_action_option(&options,FLAG_DUMP_REQUEST );
+ wsman_client_add_selector(&options, "Name", argv[1]);
+ doc = wsman_invoke(cl, RESOURCE_URI, options,
+ "StopService", NULL);
+ ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
+ ws_xml_destroy_doc(doc);
+ } else if ( argv[1] ) {
+ if (dump) wsman_set_action_option(&options,FLAG_DUMP_REQUEST );
+ wsman_client_add_selector(&options, "Name", argv[1]);
+ doc = ws_transfer_get(cl, RESOURCE_URI,
+ options);
+ if (doc) {
+ WsXmlNodeH node = ws_xml_get_soap_body(doc);
+ if (ws_xml_get_child(node, 0, RESOURCE_URI , CLASSNAME )) {
+ CIM_Servie *service = ws_deserialize(wsman_client_get_context(cl),
+ node,
+ CIM_Servie_TypeInfo, CLASSNAME,
+ RESOURCE_URI, NULL,
+ 0, 0);
+ desc = 1;
+ status = 1;
+ print_info(service);
+ }
+ }
+ ws_xml_destroy_doc(doc);
+ }
+
+ if (uri) {
+ u_uri_free(uri);
+ }
+
+ destroy_action_options(&options);
+ wsman_release_client(cl);
+ return 0;
}
diff --git a/examples/wsmid_identify.c b/examples/wsmid_identify.c
index 654c9eb..641d0f4 100644
--- a/examples/wsmid_identify.c
+++ b/examples/wsmid_identify.c
@@ -39,8 +39,7 @@
#include <time.h>
-#include "wsman-client-api.h"
-#include "wsman-xml-serializer.h"
+#include "wsman-api.h"
struct __wsmid_identify
{
@@ -134,7 +133,7 @@ fprintf( stderr, "wsman_create_client( host %s, port %d, path %s, scheme %s, use
wsmid_identify *id = ws_deserialize(wsman_client_get_context(cl),
soapBody,
wsmid_identify_TypeInfo, "IdentifyResponse",
- XML_NS_WSMAN_ID, XML_NS_WSMAN_ID,
+ XML_NS_WSMAN_ID, NULL,
0, 0);
if (vendor)
diff --git a/src/wsman.c b/src/wsman.c
index 228a639..4ad810c 100644
--- a/src/wsman.c
+++ b/src/wsman.c
@@ -63,8 +63,6 @@ wsman_output(WsManClient *cl, WsXmlDocH doc)
err = wsman_client_get_last_error(cl);
if (err != WS_LASTERR_OK) {
- fprintf(stderr, "HTTP transport error : %s\n",
- wsman_transport_get_last_error_string(err));
return;
}
if (!doc) {