troubleshooting Question

500 error when connecting to a http site (SipFoundry)

Avatar of mailBoy2
mailBoy2Flag for New Zealand asked on
LinuxProgrammingJava
1 Comment1 Solution875 ViewsLast Modified:
I get the error below when trying to conenct to a WSDL for my SipFoundry (application) installation.
I've attached in the code that requests the page, the stuff I've added in to get around the SSL issues and also pasted the the error below.
This is all running in Tomcat & Spring and is trying to call the WSDL on the "SipFoundry" server (sip.xxx.co.nz - NOTE THIS IS NOT REAL) - I can get to this HTTPS url in a browser no problems.
- So points will be given out to who ever offers the solution!!!


IOExceptionServer returned HTTP response code: 500 for URL: https://sip.xxx.co.nz:8443/sip
xconfig/services/UserService?wsdl
java.io.IOException: Server returned HTTP response code: 500 for URL: https://sip.xxx.co.n
z:8443/sipxconfig/services/UserService?wsdl
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.ja
va:1174)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnec
tionImpl.java:234)
        at nz.co.serendipityit.portal.service.PhoneUtils.sendTheMessage(PhoneUtils.java:25
2)
        at nz.co.serendipityit.portal.service.PhoneUtils.sendMessage(PhoneUtils.java:108)
        at nz.co.serendipityit.portal.service.PhoneUtils.getUserByName(PhoneUtils.java:62)

        at nz.co.serendipityit.portal.web.BuyService.findUserInPhoneSystem(BuyService.java
:28)
        at nz.co.serendipityit.portal.web.WelcomeController.handleRequest(WelcomeControlle
r.java:131)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(Simpl
eControllerHandlerAdapter.java:48)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.
java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.j
ava:809)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServle
t.java:523)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:45
3)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil
terChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain
.java:157)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
214)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextVal
ve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
152)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:102)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:10
9)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.j
ava:104)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnecti
on(Http11Protocol.java:705)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:6
83)
        at java.lang.Thread.run(Thread.java:595)

//Code that requests the page:
HttpsURLConnection httpUrlConn = (HttpsURLConnection)phone_url.openConnection();
			
			httpUrlConn.setRequestMethod("POST");
			httpUrlConn.setRequestProperty("Content-Type", "text/xml");
			httpUrlConn.setRequestProperty("Accept", "text/xml");
			httpUrlConn.setRequestProperty("axis.transport.version","HTTP/1.1");
			httpUrlConn.setRequestProperty("User-Agent","Axis/1.4");
			httpUrlConn.setRequestProperty("Content-Length",""+message.length());
			httpUrlConn.setRequestProperty("SOAPAction", "\"\"");
			httpUrlConn.setDoOutput(true);
			httpUrlConn.setFollowRedirects(true);
 
			System.out.println("SENDING!!!!!!!!!!!!!!!!!!!!!!\n"+message);
			
			java.io.OutputStream out = httpUrlConn.getOutputStream();
			java.io.OutputStreamWriter wout = new java.io.OutputStreamWriter(out);
 
 
 
 
//I have  the following in my Java class to get arround SSL issues:
//FIX HTTPS ISSUES
 
			javax.net.ssl.HostnameVerifier hv = new javax.net.ssl.HostnameVerifier() {
			    public boolean verify(String urlHostName, javax.net.ssl.SSLSession session) {
			        System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());
			        return true;
			    }
			};
			 
			HttpsURLConnection.setDefaultHostnameVerifier(hv);
			
	    // Create a trust manager that does not validate certificate chains
	       javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[]{
	           new javax.net.ssl.X509TrustManager() {
	               public java.security.cert.X509Certificate[] getAcceptedIssuers() {
	                   return null;
	               }
	               public void checkClientTrusted(
	                   java.security.cert.X509Certificate[] certs, String authType) {
	               }
	               public void checkServerTrusted(
	                   java.security.cert.X509Certificate[] certs, String authType) {
	               }
	           }
	       };
	       
	       // Install the all-trusting trust manager
	       try {
	    	   javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
	           sc.init(null, trustAllCerts, new java.security.SecureRandom());
	           HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
	       } catch (Exception e) {
	       }
	       
	       java.net.Authenticator.setDefault(new PhoneAuthenticator());
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros