Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

NAV 2009 WebService Connection Refused

Posted on by 10

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 ? 

*This post is locked for comments

  • cuge Profile Picture
    cuge 10 on at
    RE: NAV 2009 WebService Connection Refused

    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.

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: NAV 2009 WebService Connection Refused

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

  • cuge Profile Picture
    cuge 10 on at
    RE: NAV 2009 WebService Connection Refused

    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 ? 

  • Suggested answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: NAV 2009 WebService Connection Refused

    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.

  • Suggested answer
    Alexander Ermakov Profile Picture
    Alexander Ermakov 28,094 on at
    RE: NAV 2009 WebService Connection Refused

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

  • cuge Profile Picture
    cuge 10 on at
    RE: NAV 2009 WebService Connection Refused

    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.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: NAV 2009 WebService Connection Refused

    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.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: NAV 2009 WebService Connection Refused

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans