简体   繁体   English

C#Web服务在控制台中工作,但不在IIS服务器上的asp.net网站上工作

[英]C# Web service works in console but not from asp.net website on IIS server

I'm using a web service which works fine when I run it on my machine in an ASP.NET application using the default IIS Express VS 2010 comes with. 我正在使用一个Web服务,当我使用默认的IIS Express VS 2010附带的ASP.NET应用程序中运行它时,它可以正常工作。 However, when I move it to our server with IIS I get the error: 但是,当我使用IIS将其移动到我们的服务器时,我收到错误:

Error: There was no endpoint listening at 'web service name here' that could accept the message. 错误:没有端点正在侦听可以接受该消息的“此处的Web服务名称”。 This is often caused by an incorrect address or SOAP action. 这通常是由错误的地址或SOAP操作引起的。

'web service name here' is just a placeholder I put for this post. 'web service name here'只是我为此帖添加的占位符。 It has the right web service name. 它具有正确的Web服务名称。

So I pulled out the small login code that this is failing on into a console application and ran that from the IIS server and it worked! 所以我将这个失败的小登录代码拉出到控制台应用程序中并从IIS服务器运行它并且它工作正常! So I have to assume this is some kind of permissions issue with the IIS server on how it's running my web service code? 所以我不得不假设这是IIS服务器如何运行我的Web服务代码的某种权限问题? In my ASP.NET program I have a separate DLL that handles the web service. 在我的ASP.NET程序中,我有一个单独的DLL来处理Web服务。 The ASP.NET application fires off a separate thread that uses the DLL I made that uses the web service. ASP.NET应用程序触发一个单独的线程,该线程使用我制作的使用Web服务的DLL。 Is it something to do with the separate thread permissions maybe? 这可能与单独的线程权限有关吗? Any ideas? 有任何想法吗?

Your first step when faced with this sort of issue is to search your config files for "web service name here" (or if this isn't actually the message you're getting the address given in the message). 遇到此类问题时,您的第一步是在配置文件中搜索“此处的Web服务名称”(或者,如果这实际上不是您收到消息中给出的地址的消息)。 My suspicion is somewhere you'll have a WCF reference set up which needs a proper IP address. 我怀疑你的WCF参考设置需要一个合适的IP地址。

Once you've got the address (assuming it looks valid) you need to check you can access it from the machine which is having the difficulties - it may be a firewall issue. 一旦你有了地址(假设它看起来有效),你需要检查你是否可以从有困难的机器上访问它 - 这可能是防火墙问题。

Now that you've established that your console application is connecting correctly from the same machine the next step is to check that both your IIS App Pool and Console application are running under the same user account/permissions. 现在您已经确定控制台应用程序正在从同一台计算机正确连接,下一步是检查IIS应用程序池和控制台应用程序是否在相同的用户帐户/权限下运行。 It may be that one identity has permission to access the network/internet and the other one doesn't. 可能是一个身份有权访问网络/互联网而另一个身份没有。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM