我正在嘗試向我的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>
嘗試添加引用我n'WcfTestClient.exe'應用程序。 https://docs.microsoft.com/en-us/dotnet/framework/wcf/wcf-test-client-wcftestclient-exe –
此外,您可以使用'svcutil.exe'生成服務模型代碼。 https://docs.microsoft.com/en-us/dotnet/framework/wcf/servicemodel-metadata-utility-tool-svcutil-exe –
嘗試WcfTestClient,進度欄完成50%後,打開一個新窗口但會凍結,但我可以在後面的狀態欄中看到:'無法添加服務。服務元數據可能無法訪問。確保您的服務正在運行並展示元數據。 – kaycee