本人写了个WebService,在本地项目中单独浏览WebService可以成功显示,于是我就在项目中写了个测试页面调用本地WebService中的方法结果报:由于目标机器积极拒绝,无法连接。 127.0.0.1:12521]
以下是错误信息:
[SocketException (0x274d): 由于目标机器积极拒绝,无法连接。 127.0.0.1:12521]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224
[WebException: 无法连接到远程服务器]
System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +1868961
System.Net.HttpWebRequest.GetRequestStream() +13
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +103
localhost.WebService.ToRegister(String xml) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web\69e3d9e1\ce94251f\App_WebReferences.csqx7war.0.cs:110
UserRegister.butYes_Click(Object sender, EventArgs e) in f:\CardProject\Web\UserRegister.aspx.cs:43
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
大家帮忙看看,谢谢大家了!(这个问题出现多次了)
------解决方案--------------------
127.0.0.1:12521
端口问题,去掉端口
修改引用WS的配置文件,将其中的 <endpoint address="http://localhost:12521/webservice/getTree.asmx"
改成
<endpoint address="../webservice/getTree.asmx"