Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client C API Programmer's Guide | Using Request-Reply | The Server | Checking Subscription and Publishing Permissions
 
Checking Subscription and Publishing Permissions
The server shown in the example below checks to see if it has permission to subscribe to the request event and to deliver the appropriate reply event. The awCanPublish function is used to determine if the Broker client has the necessary permissions to deliver the various reply events. In the following example, the application expects that it might have to deliver the following event types:
Event Type
Description
Adapter::error
Used to indicate that an exception occurred in the processing of the event.
Adapter::ack
Used if the infoset for Sample::Request specifies that a simple success or failure indication is all that is expected.
Sample::Reply
Used if the infoset for Sample::Request defines a specific event type as a response.
The following example shows how the awCanPublish function is used to check event publishing and subscription permissions:
BrokerBoolean b;
BrokerClient c;
. . .
/* Create a client */
. . .
/* Check if can publish */
err = awCanPublish(c,"Sample::Reply",&b);
if (err != AW_NO_ERROR) {
printf("Error on awCanPublish\n");
return 0;
}
if (b == 0) {
printf("got false on awCanPublish for Sample::Reply\n");
return 0;
}
err = awCanPublish(c,"Adapter::error",&b);
if (err != AW_NO_ERROR) {
printf("Error on awCanPublish\n");
return 0;
}
if (b == 0) {
printf("got false on awCanPublish for Adapter::error\n");
return 0;
}
err = awCanPublish(c,"Adapter::ack",&b);
if (err != AW_NO_ERROR) {
printf("Error on awCanPublish\n");
return 0;
}
if (b == 0) {
printf("got false on awCanPublish for Adapter::ack\n");
return 0;
}
/* Check if can subscribe to the request event */
err = awCanSubscribe(c,"Sample::Request",&b);
if (err != AW_NO_ERROR) {
printf("Error on awCanSubscribe\n");
return 0;
}
if (b == 0) {
printf("got false on awCanSubscribe\n");
return 0;
}
/* Subscribe to the request event */
err = awNewSubscription(c,"Sample::Request",NULL);
if (err != AW_NO_ERROR) {
printf("Error on awNewSubscription\n");
return 0;
}
. . .