【发布时间】:2018-03-17 03:53:11
【问题描述】:
我正在尝试向我的 VS2015 项目添加服务引用。该服务在 Azure VM 中托管的 Windows Server 2012 中的 IIS 上发布。这是我第一次在 Azure VM (Windows Server 2012) 中托管服务,所以我不知道我可能做错了什么。
我可以在我的网络浏览器中正常访问 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>
【问题讨论】:
-
尝试在
WcfTestClient.exe应用程序中添加引用。 docs.microsoft.com/en-us/dotnet/framework/wcf/… -
此外,您可以使用
svcutil.exe生成服务模型代码。 docs.microsoft.com/en-us/dotnet/framework/wcf/… -
试过WcfTestClient,进度条完成50%后,新窗口打开但卡住了,但我可以在后面的状态栏中看到:
Failed to add service. Service metadata may not be accessible. Make sure your service is running and exposing metadata。 -
所以元数据没有被提供者暴露,你仍然可以使用
svcutil.exe来生成服务模型。并将生成的文件和配置添加到您的应用程序中。 -
我已更新我的帖子以包含更多 web.config 部分。我会尝试 svcutil
标签: c# web-services wcf azure visual-studio-2015