I have a partner that is wanting to POST their xml to our Trading Networks. Searching the forums and documentation I cannot find an example of code to do this, so I have attempted to write my own - but it will not work. Can anyone tell me what I am doing wrong?
Thanks
import java.net.;
import java.util.;
import java.io.*;
public class testPost2TN
{
public static void main(String args) throws Exception
{
try
{
// Open HTTP connection
//URL url = new URL(“http://localhost:8080/testServlet.jsp”);
URL url = new URL(“http://user:pswd@TNURL:5555/invoke/wm.tn/receive”);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
// Set the appropriate HTTP parameters.
httpConn.setRequestProperty(“Content-Type”,“text/xml; charset=utf-8”);
httpConn.setDoOutput(true);
// Set the Action header
httpConn.setRequestMethod( “POST” );
// Post the message.
OutputStream out = httpConn.getOutputStream() ;
String xmldata = “TESTUSERPASSWORD”;
byte requestXML = xmldata.getBytes();
out.write(requestXML);
out.close() ;
}
catch (Exception e)
{
System.out.println(“Exception Message\n-----------------”);
System.out.println(e);
}
}
}
When I run this code to a jsp servlet (commented out) I have on my local machine the xml gets displayed just like it should. When I cut and paste the actual URL and data to the Address line in IE it posts to TN so I dont have the wrong user/password, etc.
http://user:pswd@TNURL:5555/invoke/wm.tn/receive?$xmldata=TESTUSERPASSWORD
Since that works in IE I tried opening the URL with the above and that doesnt work either.
I compiled and ran the code pasted above and get the following error:
Exception Message
java.net.UnknownHostException: TNURL
When I run it with the actual URL, user and password I get no error message and TN has no information.
Please help.