調用WebService出錯。
現在有兩個程序都需要兩個WebService。兩個WebService的代碼差不多。
但有一個程序就經常會遇到如下的情況,而另一個就不會。
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted 127.0.0.1:1979 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetRequestStream() at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at DBSelect.DBSelect.GetActiveCriteria(String AppraisalNo, String company, String cost_center, String Badge) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\qprs\37813ce2\f483149b\App_WebReferences.vzuemjtn.2.cs:line 2694 at clsPdfData.PaddingData(DataSet ds1, String strAppNo, String badge, Int32 intCount, DataTable dtHistory) in c:\Documents and Settings\amswychung\My Documents\SourceCode\QPRS\App_Code\clsPdfData.cs:line 47 at clsPdfData.printPDF(DataTable dtGroup, Int32 group, String[]& filelist, String prefix, String Remark) in c:\Documents and Settings\amswychung\My Documents\SourceCode\QPRS\App_Code\clsPdfData.cs:line 400 System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted 127.0.0.1:1979 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetRequestStream() at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at DBSelect.DBSelect.GetWorkDesc(String AppraisalNo, String Badge, String Company) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\qprs\37813ce2\f483149b\App_WebReferences.vzuemjtn.2.cs:line 2745 at clsPdfData.printPDF(DataTable dtGroup, Int32 group, String[]& filelist, String prefix, String Remark) in c:\Documents and Settings\amswychung\My Documents\SourceCode\QPRS\App_Code\clsPdfData.cs:line 209 System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted 127.0.0.1:1979 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetRequestStream() at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at DBSelect.DBSelect.GetWorkDesc(String AppraisalNo, String Badge, String Company) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\qprs\37813ce2\f483149b\App_WebReferences.vzuemjtn.2.cs:line 2745 at clsPdfData.printPDF(DataTable dtGroup, Int32 group, String[]& filelist, String prefix, String Remark) in c:\Documents and Settings\amswychung\My Documents\SourceCode\QPRS\App_Code\clsPdfData.cs:line 209
------解决方案--------------------
一个端口只能做一件事,估计是两个冲突了
[解决办法]
你引用的那个WS服务,去掉端口号,使用默认的80端口。
127.0.0.1:1979
修改WS的配置文件将类似下面的改成相对路径
"http://localhost:2188/AutoCompleteService.asmx"
=》
"../AutoCompleteService.asmx"