HI,
I have external service referenced in c#class library. i have added dll in dynamics ax folder and added dll references to dynamics ax. I have global variable ServiceReference1.NtosServiceSoapClient se;
if I add code se = new ServiceReference1.NtosServiceSoapClient() in c# class library; dynamics ax throws error CLR Object couldn't be created , on that line.
I tried to use different approach and initialized variable like this
var remoteAddress = new System.ServiceModel.EndpointAddress("www.revenue.mof.ge/.../ntosservice.asmx"); System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(); binding.MaxReceivedMessageSize = Int32.MaxValue; se= new ServiceReference1.NtosServiceSoapClient(binding, remoteAddress);if I declare variable like this , code works, But It throws exception after calling service methods too many times in a little timespan
can anyone tell me why this error might occuring ?CLR Object couldn't be created . I have a guess, that code doesn't see config file , but I have added config file with dll , in bin folder
*This post is locked for comments
It seems that the constructor of your C# class throws an exception. Debug the C# code called from X++.
I can't comment on the error about crashing AX without more information about what you're doing.
I tried , deploying service from visual studio . but that was not an issue . I am just testing things in my server .
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. ---> System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace --- Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Above is the error which is thrown by Code after calling service methods about 500 - 600 times.
I have written
se = new ServiceReference1.NtosServiceSoapClient()
in C# class constructor . so if i write new Myclass()(c# class referenced in dax) in x++ it says clr object couldn't be created . when i debug with visual studio it doesnt't give me more information regarding this error, just stops process on above line .
I have written solution in x++ .But I want to rewrite solution in c# , because there is very unusual case , which I cant figure out . if I put breakpoint in x++ on service call , dynamics ax crashes . i am pressing (debug to visual studio button) and in visual studio error is saying
Unhandled exception at 0x76FF5934 (ntdll.dll) in ax.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77011378).
i hit continue button and everything works fine after that . in user side , it can crash unexpectedly and with same error. this is the reason I want to write solution in c# .
A better approach than dealing with the DLL file manually (imagine how you'll deploy it to clustered AOS servers in production...) is adding the VS project to AOT and configure it for automatic deployment.
Regarding the error about too many requests, it would help if you mentioned the exact type of exception and message, but it sounds like that you're not closing the channel after making requests. I suggest you review you code in this area.
Regarding your other error, you said that you added "se = new ServiceReference1.NtosServiceSoapClient() in c# class library" and then you got an error in AX, but you didn't tell us anything about your code in AX. Please add this information; we can't find bugs in completely unknown X++ code.
It's possible to load information about endpoint address and binding from the configuration file, you just have to create the client in the recommended way, i.e. via AifUtil::createServiceClient(). You may want to look at an example in documentation: Walkthrough: Calling an External Web Service from X++.
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156