0

I am getting a java.io.IOException when I tried to access webservices insdie a jsp page.

java.io.IOException: Server returned HTTP response code: 500 for URL:

It shows null when I tried printing out the error.

Webservices are working fine when I access it through postman. Also this worked fine before using https.

Below is my code.

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        System.out.println("logged in url parameter");
        String urlParameters = "args0={username}&args1={password}".replace("{username}",wsUsername).replace("{password}",wsPassword);
        System.out.println(urlParameters);
        System.out.println("wsUrl");
        System.out.println(wsUrl);
        connection.setDoOutput(true);
        DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
        wr.writeBytes(urlParameters);
        wr.flush();
        wr.close();


        BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()))
        Pattern pattern = Pattern.compile(".+<ns:return>(.+)</ns:return>.+");

java.io.IOException: Server returned HTTP response code: 500 for URL: https://xxx.xxx/nyx/services/ServiceManager/getFormCategories?args0=DEU&args1=&response=application/json INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1913) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1501) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1499) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/java.security.AccessController.doPrivileged(Native Method) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/java.security.AccessController.doPrivilegedWithCombiner(AccessController.java:793) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:245) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/java.net.URL.openStream(URL.java:1117) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.jsp._005fws.getFormCategories_jsp._jspService(getFormCategories_jsp.java:318) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) INFO | jvm 1 | 2019/09/17 11:38:29 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) INFO | jvm 1 | 2019/09/17 11:38:29 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) INFO | jvm 1 | 2019/09/17 11:38:29 | at nl.planon.tomcat.ForgotPasswordFilter.doFilter(ForgotPasswordFilter.java:78) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) INFO | jvm 1 | 2019/09/17 11:38:29 | at nl.planon.webrequestsigner.WebRequestSignerFilter.doFilter(WebRequestSignerFilter.java:67) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) INFO | jvm 1 | 2019/09/17 11:38:29 | at nl.planon.owasp.valve.WhitelistHTTPMethodsValve.invoke(WhitelistHTTPMethodsValve.java:72) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:291) INFO | jvm 1 | 2019/09/17 11:38:29 | at nl.planon.owasp.valve.WhitelistHTTPMethodsValve.invoke(WhitelistHTTPMethodsValve.java:72) INFO | jvm 1 | 2019/09/17 11:38:29 | at nl.planon.owasp.valve.XSSProtectionHeaderValve.invoke(XSSProtectionHeaderValve.java:175) INFO | jvm 1 | 2019/09/17 11:38:29 | at nl.planon.tomcat.AddHeaderValve.invoke(AddHeaderValve.java:117) INFO | jvm 1 | 2019/09/17 11:38:29 | at nl.planon.tomcat.ClickjackHostValve.invoke(ClickjackHostValve.java:107) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) INFO | jvm 1 | 2019/09/17 11:38:29 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) INFO | jvm 1 | 2019/09/17 11:38:29 | at java.base/java.lang.Thread.run(Thread.java:834)

Shelly
  • 410
  • 7
  • 26
  • What do the server logs say? Your client logs indicate a server error. – Kayaman Sep 17 '19 at 10:12
  • @Kayaman Please check the edited problem. This is what is in my wrapper/default.log. – Shelly Sep 17 '19 at 10:25
  • Why do your `POST` parameters look exactly like `GET` parameters? How does your postman request look like? – Kayaman Sep 17 '19 at 10:30
  • web 4_97.w# – Shelly Sep 17 '19 at 10:53
  • Well, you're posting a `SOAP` message from postman, but you're not doing the same in Java code. I suggest some searching on how to access SOAP webservices in Java. – Kayaman Sep 17 '19 at 11:05
  • But this is creating a session and I can see the session id in the logs. I am getting this error in this line code. connection.getInputStream()? – Shelly Sep 18 '19 at 11:54
  • I know where you're getting the error, it says it in the stacktrace. It also says the server replied with [500](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500). You need to access the logs of the "xxx.xxx/nyx/" server. If it's not a service developed by you, then you need to re-read the documentation on how to access it. It's also still unclear whether you're trying to use SOAP, REST or something else. – Kayaman Sep 18 '19 at 12:05

0 Answers0