I followed the post at http://blog.phpdeveloper.org/?p=140 to connect to a remote WebsphereMQ from PHP / Linux using the mqseries extension and was able to get the connection working.
However, the request is being sent with the username of the apache user on the client and the MQ server is rejecting the messages with error 2035. The only way I found to work around the issue is to change the profile under which apache is running to a username that has access on the MQ server.
Is there a way to pass a username when establishing connectivity to WebSphere MQ from php using mqseries? Following is the code I am using to connect:
//define connection parameters
$mqcno['MQCD'] = array(
'ChannelName' => $options['channel'],
'ConnectionName' => "$mq_host_ip($mq_host_port)",
'TransportType' => MQSERIES_MQXPT_TCP
);
// Connect to the MQ server
mqseries_connx($options['qmanager'], $mqcno, $this->_conn, $comp_code, $reason);
if ($comp_code !== MQSERIES_MQCC_OK) {
die ("Cannot open connection to server $mq_host_ip($mq_host_port) : ".$comp_code. " " .$mq_server. " " .$reason. " " );
}
Thanks, Bhaskar