Search code examples
javaxmlapacheservletscxml

How do I fix this Error 500 when trying to connect to a web service?


I am trying to connect to a cXML Web Service using Visual Studio 2010 .NET 4, and when I try to Add a Service Reference to the project using the URL I get the following error (i have masked the url for privacy) why am I getting this error and how can I connect to the web service?...

There was an error downloading 'http://00.00.00.00:8080/xml/servlet/twaaserver?svcname=x10h015'
The request failed with the error message:
--
<h1>Error: 500</h1>
<h2>Location: /xml/servlet/twaaserver</h2><b>Internal Servlet Error:</b><br> <pre>javax.servlet.ServletException
    at processService.doProcess(processService.java:447)
    at processService.run(processService.java:585)
    at twaaserver.doGet(twaaserver.java:429)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
    at org.apache.tomcat.core.Handler.service(Handler.java:287)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
    at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
    at java.lang.Thread.run(Thread.java:534)
</pre>
<b>Root cause:</b>
<pre>java.lang.NullPointerException
    at eboservice.transformDataFeeds(eboservice.java:982)
    at processService.doProcess(processService.java:279)
    at processService.run(processService.java:585)
    at twaaserver.doGet(twaaserver.java:429)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
    at org.apache.tomcat.core.Handler.service(Handler.java:287)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
    at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
    at java.lang.Thread.run(Thread.java:534)
</pre>


--.
Metadata contains a reference that cannot be resolved: 'http://00.00.00.00:8080/xml/servlet/twaaserver?svcname=x10h015'.
The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<h1>Error: 500</h1>
<h2>Location: /xml/servlet/twaaserver</h2><b>Internal Servlet Error:</b><br><pre>javax.servlet.ServletException: Warning: can't output text before document element!  Ignoring...
    at processService.doProcess(processService.java:447)
    at processService.run(processService.java:585)
    at twaaserver.doGet(twaaserver.java:429)
    at twaaserver.doPost(twaaserver.java:535)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
    at org.apache.tomcat.core.Handler.service(Handler.java:287)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
    at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
    at org.apache.tomcat.service.'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again.

Solution

  • You're right, I figured out the problem was that the web service was not a SOAP service. It is a REST service.

    The problem was that I was trying to Add A Service Reference via the Visual Studio tool. This isn't possible with this type of service I was connecting to because it uses cXML and is a REST service (it works very differently).

    In my solution I manually wrote Web Service REST calls by doing simple POST and GET requests and passed in the XML in string format.

    This worked for me... I used this tutorial: https://developer.yahoo.com/dotnet/howto-rest_cs.html