Hi Manoel,
Assuming that the gateway connection details and credentials are correct, maybe you can also check if the gateway security is set to allow any external programs to be registered.
You can also check this from the transaction SMGW and checking for the registered programs . Is XMIIRFC01 registered ?
Gateway Security Files secinfo and reginfo - Security Settings in the Gateway - SAP Library
Please also check the relevant messages in the gateway trace (also dev_rd) and the logs when you a do a connection test of XMIIRFC01 in MII
Regards,
Suneeth