所以我对Web服务的制作比较新,所以请耐心等待。503调用WebMethod时发生错误C#
我在服务器上用一个简单的helloword webmethod制作了一个Webservice,然后在IIS 7.5中进行了部署。
当调用'。 asmx'文件在我的浏览器中的服务器上,我可以看到所有的webmethods,我可以调用它们。
比我做了一个客户端应用程序,我通过Visual Studio 2013中的“添加数据源”添加了我的webservices,这没问题,它看到了我所有的webmethods。
但是,当我试图在代码中调用我的web服务并尝试调用我的webmethod时,它给了我一个例外。
Additional information: The request failed with HTTP status 503: Service Unavailable. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at WebserviceConnection.WebReference.WebService1.HelloWorld() in c:\Users\Daniel\Documents\Visual Studio 2013\Projects\WebserviceConnection\WebserviceConnection\Web References\WebReference\Reference.cs:line 78
at WebserviceConnection.Form1..ctor() in c:\Users\Daniel\Documents\Visual Studio 2013\Projects\WebserviceConnection\WebserviceConnection\Form1.cs:line 21
当我在我的服务器上运行web服务的同一应用程序时,根本没有任何问题。
所以我已经尝试了以下事情:
- 我检查我在IIS中的应用程序池,无论它是否关闭。
- 检查日志,我找不到任何明确的为什么它不工作。
我可以在任何计算机上的浏览器中调用我的webservice,它只是在我的C#应用程序中调用webmethod时给我这个错误。
客户端C#代码:
namespace ConsumeWebserviceTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
WebService1 te = new WebService1();
label1.Text = te.HelloWorld();
}
}
}
Webservice的代码:
namespace WebServiceTests
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
IM在.NET Framework 4.0中运行,所以我不知道它为什么给我这个例外。
IIS服务器正在运行,因为我仍然可以校准l我的web服务在我想要的任何计算机上的浏览器中,并且工作正常。 – danielrieske 2014-10-01 10:25:59
这意味着整合不正确,请检查 – Amit 2014-10-01 10:27:03