2

I want to call web service running in Microsoft Dynamics nav ERP i am using ksoap2 library but problem is every time i run my application it throws

java.net.ConnectException: localhost/127.0.0.1:7047 - Connection refused

Microsoft Dynamics nav is using NTLM authentication may that is the problem, please give any suggestion to solve it. Thanks in advance.

My code is

String namespace = "urn:microsoft-dynamics-schemas/codeunit/NavisionWS";
String url = "http://localhost:7047/DynamicsNAV/WS/Codeunit/NavisionWS";   
String soap_action = "urn:microsoft-dynamics-schemas/codeunit/NavisionWS:GetLoginInfo";
String method_name = "GetLoginInfo";
try
        {
              SoapObject request = new SoapObject(namespace, method_name);    
              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

               envelope.dotNet = true;   
               envelope.setOutputSoapObject(request);   
               HttpTransportSE transport = new HttpTransportSE(url);    
               transport.call(soap_action, envelope); // Receive Error here!
                    SoapObject result = (SoapObject) envelope.getResponse();
                    great = result.toString();
        }
        catch (Exception e)
        {
            e.printStackTrace();
                 great = e.toString();
                 Toast.makeText(this, great, Toast.LENGTH_LONG).show();
        }
pnuts
  • 58,317
  • 11
  • 87
  • 139
kadhirvel
  • 470
  • 1
  • 4
  • 17

2 Answers2

1

Use IP Address instead of Localhost to connect to webservice from Android

0

Have you added <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> to your manifest?

Araw
  • 2,410
  • 3
  • 29
  • 57
  • I have added in manifest – kadhirvel Oct 02 '12 at 06:24
  • Are you using an emulator or a device to run your application? – Araw Oct 02 '12 at 06:26
  • Currently using emulator and the microsoft dynamics nav is running on my system. I am trying ntlm authentication code found at samba site and url is opening from my browser, it asks for system user and password then shows the content. – kadhirvel Oct 02 '12 at 08:00
  • 2
    I got the solution. url should be "http://10.0.2.2:7047/DynamicsNAV/WS/Codeunit/NavisionWS" instead of "http://localhost:7047/DynamicsNAV/WS/Codeunit/NavisionWS" – kadhirvel Oct 04 '12 at 16:25
  • 1
    @kadhirvel Answer your own question, may be helpful to others :) – Araw Oct 04 '12 at 20:13