Skip to content

Instantly share code, notes, and snippets.

@richardschoen
Created August 27, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardschoen/9256ff3d45cfb43eac28c15af2061ded to your computer and use it in GitHub Desktop.
Save richardschoen/9256ff3d45cfb43eac28c15af2061ded to your computer and use it in GitHub Desktop.
IBM i XMLSERVICE remote command call sample
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IbmiXmlserviceStd;
namespace IbmiXmlServiceCommandSample1Cs
{
class Program
{
static void Main(string[] args)
{
String baseUrl = "http://1.1.1.1:30000/cgi-bin/xmlcgi.pgm";
String ibmiUser = "USER1";
String ibmiPass = "PASS1";
bool useHttpCredentials = false;
bool rtncmd = false;
String clCmd = "SNDMSG MSG(TESTDOTNET) TOUSR(QSYSOPR)";
XmlServicei _ibmi = new XmlServicei();
// Set credential information
_ibmi.SetUserInfoExt(baseUrl, ibmiUser, ibmiPass, useHttpCredentials);
// Run CL command and return success or failure
rtncmd = _ibmi.ExecuteCommand(clCmd);
if (rtncmd)
{
Console.WriteLine("Command was successful.");
Environment.Exit(0);
} else
{
Console.WriteLine("Command failed.");
Environment.Exit(99);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment