This is probably the wrong mailing list for your issue. This is for the Apache XML Security project. You should try one of the tomcat lists - http://tomcat.apache.org/lists.html

--Sean

Thompson, Willard wrote:
Hello,

I am trying to set up a HttpURLConnection stream from a servlet running on Tomcat to another web server within our LAN, where Tomcat is running on my desktop.

However, I keep getting the following error:

Permissions: connect,resolve

Response code: 401

Response message: Unauthorized ( The server requires authorization to fulfill the request. Access to the Web server is denied. Contact the server administrator. )

Here is my code:

url = *new* URL(urlStr);

urlConnection = url.openConnection();
httpConnection = (HttpURLConnection) urlConnection;

httpConnection.setDoOutput(*true*);

httpConnection.setRequestMethod("POST");

httpConnection.setRequestProperty("Content-type", "text/xml"); Permission permission = httpConnection.getPermission(); System./out/.println("Permissions: " + permission.getActions());
outStream = *new* PrintStream(httpConnection.getOutputStream());

outStream.println(xml);

outStream.close();

//*** Debug

*int* responseCode = httpConnection.getResponseCode();

System./out/.println("Response code: " + responseCode);
String responseMsg = httpConnection.getResponseMessage();

System./out/.println("Response message: " + responseMsg); When I run this same code within a stand alone Java app from my PC, it works just fine. I am able to connect and I get a response message of OK. One of my co-workers is able to run this code within his Tomcat instance just fine, but we are unable to figure out why my Tomcat isn’t working correctly for this.

Also, regardless of what I put in my URL string, I still get the same error, which leads us to believe that it is something with the Tomcat security. I’ve tried a number of different entries within the catalina.policy file and no luck. Of course, I’ve tried to open up the remote web server’s security permissions and still no luck. I’ve even added our remote server to my no proxy list configuration in Internet Options.

Any help would be great!

Thanks,

--Willard


Reply via email to