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?
public class testPost2TN
public static void main(String args) throws Exception
// 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.
// Set the Action header
httpConn.setRequestMethod( “POST” );
// Post the message.
OutputStream out = httpConn.getOutputStream() ;
String xmldata = “TESTUSERPASSWORD”;
byte requestXML = xmldata.getBytes();
catch (Exception 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.
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:
When I run it with the actual URL, user and password I get no error message and TN has no information.