简体   繁体   English

代理后面的IIS上无法访问Web服务

[英]Webservice not accessible on IIS, behind proxy

Spend two days looking through lots of questions but found nothing or may be I am doing something wrong. 花两天时间浏览许多问题,但什么都没发现,或者可能是我做错了事。 Basically, I am accessing an AXIS web service from inside a class library, and library is used by web application and windows service. 基本上,我是从类库内部访问AXIS Web服务,并且该库由Web应用程序和Windows服务使用。 Service reference is added to the class library, both web application and windows service can access the service, and run without any trouble inside visual studio. 服务参考已添加到类库中,Web应用程序和Windows服务都可以访问该服务,并且可以在Visual Studio中正常运行。 However when I publish the app, and install windows service, the application throws below error. 但是,当我发布该应用程序并安装Windows服务时,该应用程序将引发以下错误。

ERROR 错误
" There was no endpoint listening at https://bulkmsg.xx.wxyz.com/services/MessagingServices_1 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. " https://bulkmsg.xx.wxyz.com/services/MessagingServices_1上没有侦听终结点的端点可以接受消息。这通常是由于地址或SOAP操作不正确引起的。有关更多详细信息,请参阅InnerException(如果存在)。

WEB.CONFIG (proxy settings) WEB.CONFIG(代理设置)

<defaultProxy useDefaultCredentials="true">
  <proxy usesystemdefault="False" proxyaddress="http://10.51.10.51:8080" bypassonlocal="True" />
</defaultProxy>

I switched the settings from false to true, but I still get the same error. 我将设置从false切换为true,但是仍然遇到相同的错误。 See below the servicemodel section of web.config. 请参阅以下web.config的servicemodel部分。

WEB.CONFIG (service settings) WEB.CONFIG(服务设置)

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="MessagingServices_1SoapBinding" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="MessagingServices_1SoapBinding1" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://bulkmsg.xx.wxyz.com/services/MessagingServices_1"
          binding="basicHttpBinding" bindingConfiguration="MessagingServices_1SoapBinding"
          contract="ZainSmsService.MessagingServices_1" name="MessagingServices_1" />
    </client>
  </system.serviceModel>

Both the web application and windows service are installed on a Win 2008 server, which is connected to internet from behind the proxy. Web应用程序和Windows服务都安装在Win 2008服务器上,该服务器从代理后面连接到Internet。

Since, application is able to access web service inside visual studio but not in IIS, it looks like an permission or some setting issue with IIS, I could be wrong, but that's what I figured out. 由于应用程序能够访问Visual Studio中的Web服务,但不能访问IIS中的Web服务,因此它看起来像IIS的权限或某些设置问题,我可能错了,但这就是我想出的。 I am not sure what exactly I should change and where. 我不确定应该在什么地方更改。

UPDATE: more info 更新: 更多信息
I did some digging and managed to find this 我做了一些挖掘并设法找到了这个

Technical Information (for Support personnel) 技术信息(适用于支持人员)
Error Code: 502 Proxy Error. 错误代码:502代理错误。 Forefront TMG denied the specified Uniform Resource Locator (URL). Forefront TMG拒绝了指定的统一资源定位符(URL)。 (12202) IP Address: 10.51.10.51 (12202)IP地址:10.51.10.51
Date: 7/30/2015 6:54:58 AM [GMT] 日期:2015年7月30日6:54:58 [GMT]
Server: MUPROXY.MOXXX.GOV.XXX 伺服器:MUPROXY.MOXXX.GOV.XXX
Source: proxy 资料来源:代理

It seems that your web service crashes at startup, because of a NullReferenceException (according to the provided eventlog). 似乎由于NullReferenceException(根据提供的事件日志),您的Web服务在启动时崩溃了。 Therefore the web service could not be reached, so you get this "[...] no endpoint listening [...]" error message. 因此无法访问Web服务,因此您收到此“ [...没有端点侦听]”错误消息。

Can you try to find out, where exactly this NullReferenceException occurs? 您可以尝试找出此NullReferenceException的确切位置吗?

Also - if this is possible - you can try to access the webservice directly at the webserver, by just entering the link into a webbrowser. 另外-如果可能的话-您可以尝试通过直接在Web浏览器中输入链接来直接在Web服务器上访问Web服务。 You can get more information if you try this directly at the server. 如果直接在服务器上尝试,则可以获得更多信息。

WORK AROUND 周围的工作

I found a work around, switched from service reference to web reference and used below code to pass on proxy details. 我找到了解决方法,从服务参考切换到Web参考,并使用下面的代码传递代理详细信息。

WebProxy _proxy = new WebProxy(_config.GetAppKey("PROXY"), Boolean.Parse(_config.GetAppKey("BYPASSONLOCAL")));
                _proxy.Credentials = new NetworkCredential
                {
                    UserName = _config.GetAppKey("PROXYUSER"),
                    Password = _config.GetAppKey("PROXYPWD")
                };

XXXXSmsService.MessagingServices_1Service _xxxxProxy = new XXXXSmsService.MessagingServices_1Service();
_xxxProxy = _proxy;

Web Referecen plus above code, works like a charm. Web Referecen加上上面的代码,就像一个魅力。

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

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