问题
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();
}
回答1:
Use IP Address instead of Localhost to connect to webservice from Android
回答2:
Have you added <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
to your manifest?
来源:https://stackoverflow.com/questions/12685255/how-to-call-a-nav-webservice-from-android