MQWeb
Administrating WebSphere MQ with your browser.
AuthorityServiceController
The second part of the URI must be authservice
to call the
AuthorityServiceController. This controller can be used to get information
about the level of function supported by installed authority managers.
inquire
Get information about the level of function supported by installed authority
managers. This action executes the MQCMD_INQUIRE_AUTH_SERVICE pcf command.
On success, the returned JSON object will have a data
array, on failure an
error
object.
URL Parameters
/api/authservice/inquire/<QueueManager>
QueueManager
The name of the queuemanager. This parameter is required!
Query Parameters
AuthServiceAttrs
With the AuthServiceAttrs
parameter you can specify which attributes must be
returned from the PCF command. Multiple occurences of this parameter are
possible. The value must be a (case-sensitive) valid attribute name.
Attrs is a synonym for AuthServiceAttrs
ServiceComponent
Name of authorization service.
Example
/api/authservice/inquire/PIGEON
<?php
/*
* Inquire all authority service information for a queuemanager.
* MQWeb runs on localhost and is listening on port 8081.
*/
if ( count($argv) < 2 ) {
echo 'Please pass a queuemanager name as argument', PHP_EOL;
exit;
}
$qmgr = $argv[1];
$url = 'http://localhost:8081/api/authservice/inquire/' . $qmgr;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
if ( ($response = curl_exec($curl)) === false ) {
$err = curl_error($curl);
echo 'An HTTP error occurred while getting authority service information from '
, $qmgr
, ': '
, $err
, PHP_EOL;
} else {
$json = json_decode($response);
// When there is an error object returned, something went wrong with
// the WebSphere MQ command.
if ( isset($json->error) ) {
echo 'An MQ error occurred while inquiring status from '
, $qmgr
, PHP_EOL;
echo 'Reason Code: '
, $json->error->reason->code
, " - "
, $json->error->reason->desc
, PHP_EOL;
}
else {
if ( isset($json->data) && count($json->data) > 0 ) {
foreach($json->data as $authservice)
{
foreach($authservice->ServiceComponent->value as $serviceComponent) {
echo $serviceComponent, PHP_EOL;
}
}
}
else
{
echo "No authority services found\n";
}
}
}
JSON Object
When using an application/json POST request you can post a JSON object with names like the query parameters.
All URL parameters and query parameters are ignored except for the URL parameter for the name of the queuemanager.
There are some differences between query parameters and a JSON object:
- JSON property names are case-sensitive
- AuthServiceAttrs is a JSON array with attributenames as element.
- Synonyms can’t be used, you need to use the name of the attribute as described in the query parameters.
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(say);
use JSON;
use LWP::UserAgent;
use HTTP::Request::Common;
# This sample will show all authority service information
my $qmgr = shift;
die("Please pass me the name of a queuemanager as argument")
unless defined($qmgr);
my $json = JSON->new;
my %input = (
);
my $content = $json->encode(\%input);
my $ua = LWP::UserAgent->new;
my $req = POST 'http://localhost:8081/api/authservice/inquire/' . $qmgr;
$req->header(
'Content-Type' => 'application/json',
'Content-length' => length($content)
);
$req->content($content);
my $res = $ua->request($req);
die $res->status_line unless $res->is_success;
my $mqweb = $json->decode($res->content());
use Data::Dumper;
print Dumper($mqweb);
if ( exists($mqweb->{error}) ) {
say 'An MQ error occurred while inquiring authority services.';
say 'Reason Code: '
, $mqweb->{error}->{reason}->{code}
, ' - '
, $mqweb->{error}->{reason}->{desc};
}
else {
foreach my $authservice(@{$mqweb->{data}}) {
foreach my $serviceComponent(@{$authservice->{ServiceComponent}->{value}}) {
say $serviceComponent;
}
}
}