2017-10-05 139 views
0

我正在尝试向我的VS2015项目添加服务参考。该服务在Azure VM中托管的Windows Server 2012中的IIS上发布。这是我第一次在Azure虚拟机(Windows Server 2012)中托管服务,所以我不知道我可能做错了什么。无法将Azure VM上托管的WCF服务参考添加到VS2015项目

我可以正常访问我的Web浏览器中的TheService.svc文件(例如:http://xxxxxx.xxxxx.cloudapp.azure.com/TheService/TheService.svc)。

但是,当我尝试在我的VS项目中使用相同的地址添加服务引用时,它仅挂起:Please wait for service information to be downloaded or click Stop,并且从未下载元数据。

下面是在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> 
+0

尝试添加引用我n'WcfTestClient.exe'应用程序。 https://docs.microsoft.com/en-us/dotnet/framework/wcf/wcf-test-client-wcftestclient-exe –

+0

此外,您可以使用'svcutil.exe'生成服务模型代码。 https://docs.microsoft.com/en-us/dotnet/framework/wcf/servicemodel-metadata-utility-tool-svcutil-exe –

+0

尝试WcfTestClient,进度栏完成50%后,打开一个新窗口但会冻结,但我可以在后面的状态栏中看到:'无法添加服务。服务元数据可能无法访问。确保您的服务正在运行并展示元数据。 – kaycee

回答

0

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

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

0

它看起来像您尚未发布该服务的元数据,请尝试:

<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> 
相关问题