Problem calling webservice locally, works remotely

Got a slightly strange problem.  I've developed a small webservice that, in turn calls a second webservice (an API to a third party product over which I have no control!)  It all works fine from my development machine with the third-party API running on our webserver, but as soon as I deploy my webservice to the same server it breaks and throws the following error:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace
--- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at
System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at
System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) at
System.Threading.ExecutionContext.runTryCode(Object userData) at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at
System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at
System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace
--- at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at
RWIncidentProc.CustomerService.CustomerHandler.GetAllCustomers(Guid securityToken) in C:\Users\kenny.munro\Documents\Visual Studio 2010\Projects\RWIncidentReporting\RWIncidentProc\Web References\CustomerService\Reference.vb:line 171 at
RWIncidentProc.OnTimeFunctions.FindCustomer(Guid CustomerGUID) in C:\Users\kenny.munro\Documents\Visual Studio 2010\Projects\RWIncidentReporting\RWIncidentProc\OnTimeFunctions.vb:line 12 at
RWIncidentProc.IncidentProcessor.ProcessIncident(Byte[] Content) in C:\Users\kenny.munro\Documents\Visual Studio 2010\Projects\RWIncidentReporting\RWIncidentProc\IncidentProcessor.vb:line 58

Anyone got any ideas what's causing this?  Any help greatly appreciated!
Who is Participating?
bansidharConnect With a Mentor Commented:
This is a network issue. Normally web servers and most of the servers inside a firewall are configured not to accept connection on public IP from internal network. The firewall blocks all such connection.

Here is the solution:
1. You can use the local IP of the web server once you are inside the network. If both the applications are in the same server then you can use the IP to connect to the web service. of if it is in a different machine you can use the the local IP which you can get from the server administrator.

2. You have to run your application outside the web server network

3. Most insecure (your server admin will never allow this). ask the administrator to allow public IP access from inside the network.
Sorry, Typo in my previous post

Here are the solutions:
Here is the solution:

Best is use first solution
use the third party service's local address to connect and not the public one.
kendolondonAuthor Commented:
Never did get to the bottom of why this was happening.  Ended up hosting on a separate machine which works fine.  Thanks for the help though!
All Courses

From novice to tech pro — start learning today.