on 03-22-2010 5:54 AM
Hi,
I want to access the Host and port in UDF to pass it to a link http://host:port/AdapterFramework/ChannelAdminServlet?party=&service=&channel=*&action=status dynamically.
How can I acieve it?
Manisha
in UDF use this snippet to get host name dynamically
java.net.InetAddress.getLocalHost().getCanonicalHostName()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manisha,
No special imports are required as the statement uses builtin JAVA SDK API.
>And which host name it will return? AS JAVA?? or Central instance?
Central Instance if all stacks are in one physical machine
>Accordingly port has to pass. Is there any way to access port as well?
Not sure.....But may be we can access the SAP system Number and based on this we can guess port in dynamic fashion.
If SAP INSTANCE NUMBER= XX
then
PORT = 50000+(Instance number *100)
Note: You can also get the instance by some code logic by working on general directory structure "\usr\sap\<SAPSID>\<Instance_Name>\j2ee". Use this option if you dont find any other way.
Edited by: Praveen Gujjeti on Mar 22, 2010 12:59 PM
Hi
With this code. I am getting error:
try
{
java.net.InetAddress addr = java.net.InetAddress.getLocalHost();
String host = addr.getCanonicalHostName();
}
catch (UnknownHostException e){}
if (ProcessMode.equals("P"))
{
try{
String xyz="/AdapterFramework/ChannelAdminServlet?party=&service=&channel="Name"&action=stop";
URL server = new URL("http", host, 8XXX, xyz);
tring userPassword =Userid + ":" + Password;
String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
URLConnection uc=server.openConnection();
uc.setRequestProperty ("Authorization", "Basic " + encoding);
BufferedReader br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
while ((inputLine = br.readLine()) != null)
output+=inputLine;
br.close();
}
catch (Exception e){}
}
ERROR:
cannot resolve symbol
symbol : variable host location: class com.sap.xi.tf._MM_CommunicationChannel_Stop
_ URL server = new URL("http", host, 8xxx, xyz);
^ 1 error
Any other way to get host and port?
Manisha
Hi Manisha ,
In order to access port and hostname in java , please follow this link it has the source code ,
let me know if it suits your requirement .
http://www.roseindia.net/software-tutorials/detail/24223
Regards
Ninad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The URL you mentioned is of some channel in XI/ PI and hence the Host and port will also be of XI/ PI. For host you can use SAPSYSTEMNAME parameter.....for port i guess there is no parameter available.
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.