Avatar of mailBoy2
mailBoy2Flag for New Zealand asked on

500 error when connecting to a http site (SipFoundry)

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());

Open in new window

ProgrammingLinuxJava

Avatar of undefined
Last Comment
mailBoy2

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mailBoy2

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy