简体   繁体   English

无法将Azure VM上托管的WCF服务引用添加到VS2015项目

[英]Can't add WCF service reference hosted on Azure VM to VS2015 project

I'm trying to add a service reference to my VS2015 project. 我正在尝试向我的VS2015项目添加服务引用。 The service is published on IIS in Windows Server 2012 hosted in an Azure VM. 该服务在Azure VM托管的Windows Server 2012中的IIS上发布。 This is the 1st time I'm hosting a service inside an Azure VM (Windows Server 2012) so I don't know what I might have been doing wrong. 这是我第一次在Azure VM(Windows Server 2012)中托管服务,因此我不知道自己可能做错了什么。

I can access the TheService.svc file in my web browser normally (ie: http://xxxxxx.xxxxx.cloudapp.azure.com/TheService/TheService.svc ). 我可以正常在Web浏览器中访问TheService.svc文件(即: http://xxxxxx.xxxxx.cloudapp.azure.com/TheService/TheService.svc : http://xxxxxx.xxxxx.cloudapp.azure.com/TheService/TheService.svc )。

But when I try to add the service reference using the same adress in my VS project, it just hangs to: Please wait for service information to be downloaded or click Stop and the metadata is never downloaded. 但是,当我尝试在VS项目中使用相同的地址添加服务引用时,它只是挂在: Please wait for service information to be downloaded or click Stop并且从不下载元数据。

Here is the service configuration in the web.config: 这是web.config中的服务配置:

<system.serviceModel>
    <diagnostics>
      <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
    <bindings>
      <basicHttpBinding>
        <binding name="TestBinding" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="true" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" messageEncoding="Text">
          <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="TheService.TheService">
        <endpoint address="http://localhost/TheService/TheService.svc" binding="basicHttpBinding" bindingConfiguration="TestBinding" name="TheService_Local" contract="TheService.ITheService" />
        <host>
          <timeouts openTimeout="00:10:00" />
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>

It looks like you have not published the metadata for the service, try: 您似乎尚未发布该服务的元数据,请尝试:

 <service name="TheService.TheService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TestBinding" name="TheService_Local" contract="TheService.ITheService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <timeouts openTimeout="00:10:00" />
    </host>
  </service>

我通过在web.config转换文件中设置此属性来解决我的问题:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" xdt:Transform="SetAttributes(multipleSiteBindingsEnabled)"/>

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

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