我试图从我的Android应用程序调用自写代码单元。 但我没有得到任何价值观。 Codeunit具有“Add”功能,该功能在数据库中插入记录并返回String。
在我的Android Studio项目中,我创建了这些类 NtlmTransport JCIFSEngine 和一个我称之为Web服务的类,即Async。
String namespace = "urn:microsoft-dynamics-schemas/codeunit/AddService";
String url = "http://Xxx.xxx.xxx.xxx:XXX/DynamicsNAV80/WS/CRONUS%20AG/codeunit/AddService";
String soap_action = "urn:microsoft-dynamics-schemas/codeunit/addservice";
String method_name = "Add";
String great;
try {
SoapObject request = new SoapObject(namespace, method_name);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
PropertyInfo no = new PropertyInfo();
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
NtlmTransport ntlm = new NtlmTransport();
//ntlm.debug = true;
ntlm.setCredentials(url, "myUser", "myPassword", "myDomain", "");
ntlm.call(soap_action, envelope); //is successful
SoapObject result = (SoapObject) envelope.getResponse();
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
great = result.toString();//Error "Attempt to invoke virtual method on a null object reference" SoapPrimitive makes the Same Error
Log.e("result",great);
在我的清单文件中,我为INTERNET添加了以下权限行,
uses-permission android:name="android.permission.INTERNET"
这是我称之为Web服务的CodeUnit:
cust."No." := 'Hello World';
cust.INSERT;
Added := 'Success';
EXIT(Added)