on 03-19-2010 9:49 AM
Hi All,
I am developing an UDF, where I am accessing an URL.
But I want to pass a value from payload as a part of URL.
Like:
URL server = new URL("http://Host:port//AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=CC_name&action=stop");
String 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();
}
In this code the URL is hardcoded. But I want to pass channel name from payload(channel name is one of the sender messagetype field ). Instead of channel=CC_name I want to pass channelname inside the URL.
How to achieve this?
Any pointer?
Regards
Manisha
>
>
URL server = new URL("http://Host:port//AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=CC_name&action=stop");
>
> String 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();
> }
>
Have you tested above code,is it working fine??
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Declare one varialbe URL1 and assign value to that variable till channel name,and pass channel name as string argument to the UDF,
and create one more varailbe URLFULL,then append URL1 and Channel name to the URLFULL.
then change code like
URL server = new URL(URLFULL);
it will work
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raj,
According to your idea, the URL("http://Host:port//AdapterFramework/ChannelAdminServlet?party=&service=&channel=CC_name&action=stop") will have 3 parts.
Part 1: URL from begining to Channel i.e. http://Host:port//AdapterFramework/ChannelAdminServlet?party=&service=&channel=
Part 2: I will pass Channel Name instead of CC_Name
Part 3: end of the URL i.e. &action=stop
I dont have much Java knowledge.
Could you please explain it by code example?
Thanks for your reply.
Manisha
Edited by: Manisha Das on Mar 19, 2010 11:32 AM
I did that method and got error so i have raised this issue in SDN.
And the error was:
usr/sap/SID/DVEBMGS22/j2ee/cluster/server0/./temp/classpath_resolver/Mapd31430c0334511dfa3f0aef8ecf0e303/source/com/sap/xi/tf/_MM_Name_Stop_.java:65: empty character literal URL server = new URL("http://Host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=" + Name + ''&action=stop"); ^ /usr/sap/SID/DVEBMGS22/j2ee/cluster/server0/./temp/classpath_resolver/Mapd31430c0334511dfa3f0aef8ecf0e303/source/com/sap/xi/tf/_MM_CommunicationChannel_Stop_.java:65: unclosed character literal URL server = new URL("http://Host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=" + Name + ''&action=stop"); ^ /usr/sap/SID/DVEBMGS22/j2ee/cluster/server0/./temp/classpath_resolver/Mapd31430c0334511dfa3f0aef8ecf0e303/source/com/sap/xi/tf/_MM_CommunicationChannel_Stop_.java:65: unclosed string literal URL server = new URL("http://Host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=" + Name + ''&action=stop");
Edited by: Manisha Das on Mar 19, 2010 11:56 AM
URL server = new URL("http://Host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=" + Name + ' '&action=stop");
that is incorrect, the error you are getting is a java syntactical error
give like this.........
URL server = new URL("http://Host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=" + Name + "&action=stop");
Edited by: Praveen Gujjeti on Mar 19, 2010 5:14 PM
The URL should have single '/' after port like
http://host:port/AdapterFramework
But whereas yours is like
"http://host:port//AdapterFramework"
Use this standalone code for testing purposes. As mentioned earlier make sure that you have done settings according to this link: [Controlling a Communication Channel Externally|http://help.sap.com/saphelp_nw04/helpdata/en/45/0c86aab4d14dece10000000a11466f/content.htm]
import java.net.*;
import java.io.*;
class ExternalChannelControlXIPI
{
public static void main(String[] args)
{
try
{
//Give HostName, Port and Channel Name
URL server = new URL("http://<Host:port>/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=" + <ChannelName> + "&action=stop");
//Hardcode UserName & Password
String userPassword = "<USERNAME>" + ":" + "<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()));
String inputLine = "";
String output = "";
while (( inputLine = br.readLine()) != null)
output+=inputLine;
System.out.print(output);
br.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
- Praveen Gujjeti.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.