SBX - Search With Button

SBX - Forum Post Title

NAV 2009 WebService Connection Refused

Microsoft Dynamics NAV Forum

cuge asked a question on 15 Jul 2016 5:20 AM

Question Status

Verified

Hi all, i'm not sure my problem's cause is strictly related to NAV but here is where i'm starting from. 

I'm developing a Web Form application with .NET framework 4 which calls some functions from NAV codeunits exposed as WebServices. I have already done 3 or 4 other projects like this and all went more or less fine, only on this last project i encountered this error and i can't understand whats the cause and how to solve it. I have already spent 2 days reading all forum posts on this matter, and i see there are many, but still cant find a solution.

I'll try to provide some data about the problem as detailed as possible. 

ERROR

Stack Trace: 


[SocketException (0x274d): No connection could be made because the target machine actively refused it 127.0.0.1:7047]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +273
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +584

[WebException: Unable to connect to remote server]
   System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +1176
   System.Net.HttpWebRequest.GetRequestStream() +23
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +160
   EuroFer.WSref.WebAppUtils.GetItemPrice(String itemCode, String customerCode, Int32 itemQuant) +146
   EuroFer.InsertOrder.btn_searchItem_Click(Object sender, EventArgs e) +591
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +153
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

 

NAV


Version 2009 SP1

Codeunit succesfully published as webservice

"Dynamics Nav Business Web Services" service is running

NETWORK & SECURITY

NAV Server is running on server A, while my project is published with IIS in server B, both A and B are inside company network.  
I contacted their system admin who said there are no firewall, router or proxy rules blocking the connecction.

Note: If i copy the link to the webservice in my project reference and i paste it in the browser i actually get a good answer, it shows me the xml fiel with all the functions i'm supposed to see. 

CODE

I Added the reference to the project as usual, indeed its all working fine while i'm previewing it from visual studio in debug mode, the error arises when i publish the application on IIS.

Any ideas ? 

Reply
Vishal Salot responded on 15 Jul 2016 6:37 AM
My Badges
Verified Answer

Try to execute your Project (Web Service) from Server A (NAV Server) and see if it works.

This will ensure that, there is nothing wrong in your code except the Firewall settings.

Also, use proper IP Address (Instead of Local host) , check if proper rights are given in domain, NAV & SQL.

Reply
Suresh Kulla responded on 15 Jul 2016 8:57 AM
Suggested Answer

Try SOAPUI tool to test the connection and also try using IP address if you are using the name.  You already mentioned that you have checked the proxy rules, but try to check if the webservice port is open or not.

Reply
cuge responded on 15 Jul 2016 9:34 AM

Thankyou for your answers, in my service reference i'm not using localhost actually i set the specific internal address, like: 10.xx.xx.x/.../WS*comapny name*/Codeunit/WebAppUtils.

Typing this same address on the browser gives me a correct response, so i guess the port is open and working fine, we also tried a telnet request on that port before and was already fine.

About SQL permissions, our users and ntauthority service got db_owner rights.

To test the application from NAV server i'll have to install IIS there, so i will try Monday i think, meanwhile i'll check this soapui tool.

Reply
Alexander Ermakov responded on 15 Jul 2016 1:58 PM
My Badges
Suggested Answer

Check also the antimalware software, sometimes it is an issue.

Reply
RockWith NAV responded on 15 Jul 2016 2:46 PM
My Badges
Suggested Answer

Some of the most common Solutions for above are.

1. Firewall Settings

2 .Antivirus with Firewall

While doing on VM you need to cross-check that the Port is open.

Reply
cuge responded on 19 Jul 2016 9:17 AM

Ok, i got some updates on this topic, today i installed IIS where Nav server is running and so i could try to run the application there, i thought it would work but actually i got a similar error, even if this time is probably telling us more:

[SoapException: The login failed when connecting to SQL Server 10.16.103.9.]
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +690429
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +327
   EuroFer.WSref.WebAppUtils.GetItemPrice(String itemCode, String customerCode, Int32 itemQuant) +146
   EuroFer.InsertOrder.btn_searchItem_Click(Object sender, EventArgs e) +591
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +153
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804


Is this caused by some autentication problems ? Maybe my service is trying to connect with a different user.... is it something i should fix in my code or something i should change in sql server settings ? 

Reply
Suresh Kulla responded on 19 Jul 2016 10:34 AM
Verified Answer

Make sure the Service user who is running the NAV Services/Web Service has proper permissions on the SQL Server for that database.

Reply
cuge responded on 20 Jul 2016 10:23 AM

Thankyou all for your suggestions that helped me to nail down the problem, I managed to make it work, the actual problem was that (in IIS) my application Pool  was using default identity 'ApplicationPoolIdentity' which didn't have proper rights for sql server, so i changed that identity with our admin user and this made the trick.

Reply
Vishal Salot responded on 15 Jul 2016 6:37 AM
My Badges
Verified Answer

Try to execute your Project (Web Service) from Server A (NAV Server) and see if it works.

This will ensure that, there is nothing wrong in your code except the Firewall settings.

Also, use proper IP Address (Instead of Local host) , check if proper rights are given in domain, NAV & SQL.

Reply
Suresh Kulla responded on 19 Jul 2016 10:34 AM
Verified Answer

Make sure the Service user who is running the NAV Services/Web Service has proper permissions on the SQL Server for that database.

Reply
Suresh Kulla responded on 15 Jul 2016 8:57 AM
Suggested Answer

Try SOAPUI tool to test the connection and also try using IP address if you are using the name.  You already mentioned that you have checked the proxy rules, but try to check if the webservice port is open or not.

Reply
Alexander Ermakov responded on 15 Jul 2016 1:58 PM
My Badges
Suggested Answer

Check also the antimalware software, sometimes it is an issue.

Reply
RockWith NAV responded on 15 Jul 2016 2:46 PM
My Badges
Suggested Answer

Some of the most common Solutions for above are.

1. Firewall Settings

2 .Antivirus with Firewall

While doing on VM you need to cross-check that the Port is open.

Reply

SBX - Two Col Forum

SBX - Migrated JS