2

I wrote today my own web service and i want to reach this sever with my android smartphone. I did this by following this tutorial: http://javatutorialspoint.blogspot.nl/2012/02/simple-java-web-service-client-using.html

And it seems to work because i get the right result when i call this page : localhost:8080/WebServiceV2/services/Calculator?wsdl

But when I try to connect with my smartphone the app throws an exception(HTTP request failed, HTTP status: 500)

private static String SOAP_ACTION = "http://apptomap.de/add";
private static String NAMESPACE = "http://apptomap.de";
private static String METHOD_NAME = "add";
private static String URL = "http://192.168.1.34:8080/WebServiceV2/services/Calculator?wsdl";


SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);          
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);

HttpTransportSE ht = new HttpTransportSE(URL);
ht.call(SOAP_ACTION, envelope);
final  SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
final String str = response.toString();

This is my code to connect with the web service and I get the exception at this line -> ht.call(SOAP_ACTION, envelope);

It is exactly the same problem like this: Soap Throws java.io.IOException: HTTP request failed, HTTP status: 500

Has anyone an idea to solve this problem?

Edit: I added the premission to connect with the internet

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Dennis
  • 143
  • 5
  • 17

3 Answers3

0

I was receiving this error with a web method that accepts two parameters from an Android application running the CallSoap java code with the goal to write to an SQL Server 2008 database hosted on my local machine.

This may not be applicable to the tutorial you are testing; however, adding a new user login (i.e. security permissions - NT AUTHORITY\Network Service) to the database helped.

Additionally, the error occurred when sending a string holding too many characters as a parameter to the web method. As an example: "01010101010110101010101010101010101010" will throw the java exception error but "0101010" will not.

My guess a restriction on the amount of bytes able to be sent as a parameter or a data type mismatch.

Adam
  • 161
  • 1
  • 5
0

Download and install the protocol analyzer wireshark from www.wireshark.org/download.html on your web server.

Start wireshark, filter http or the tcp port your web server responds to.

Now run your android app to the web service.

As the snoops are ongoing on wireshark, you will be able to see the faultstring for the ksoap and debug accordingly.

I was having issues with the dates. No fault code was reported but from the faultstring I could see "Server was unable to read request; There is an error in XML document. The string 12-10-2013' is not valid Allxsd value"

Debugging this way, you will know which errors your app is sending and debug according.

For those using linux web server pls learn how to use tcpdump.

0

Surround the call with a SoapFault try/catch

try {
    ht.call(SOAP_ACTION, envelope);
} catch (SoapFault soapFault) {

soapFault will contain the error message returned from the server, should help you to figure out what's wrong.

mir
  • 371
  • 2
  • 5