![](/img/trans.png)
[英]Error while consuming one WCF Service (hosted on Windows Service) from another WCF Service (self hosted)
[英]Credential Error while consuming the WCF Service hosted in Azure App Service
我已经使用“云服务>> WCF Web角色”创建了WCF服务(如下所示)。 ( 这只是我进行的一项测试练习,以确保可以将WCF托管在Azure App Service中并通过使用C#作品创建的外部应用程序进行连接。 )
[在此处输入图像描述] 1
我的WebConfig如下:
<?xml version="1.0"?> <configuration> <system.diagnostics> <trace> <listeners> <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> <!--<filter type="" />--> </add> </listeners> </trace> </system.diagnostics> <system.web> <compilation debug="true" targetFramework="4.6.1" /> <authentication mode="None"/> </system.web> <system.serviceModel> <!--DECLARE BINDINGS--> <bindings> <wsHttpBinding> <binding name="CustomBinding" openTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" sendTimeout="00:20:00" > <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> <message algorithmSuite="Default" clientCredentialType="None"/> </security> </binding> </wsHttpBinding> </bindings> <!--DECLARE BEHAVIOUR--> <behaviors> <serviceBehaviors> <behavior name="CustomBehaviour"> <!-- To avoid disclosing metadata information, set the value 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> <!--CREATE SERVICE WITH ENDPOINTS--> <services> <!-- Service For Main Implementation--> <service name="DolphinBimUserRegistration.Service1" behaviorConfiguration="CustomBehaviour"> <endpoint address="DBWsHttp" binding="wsHttpBinding" bindingConfiguration="CustomBinding" contract="DBIMInterface.IDBIMService"/> </service> </services> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <!-- To browse web app root directory during debugging, set the value below to true. Set to false before deployment to avoid disclosing web app folder information. --> <directoryBrowse enabled="true"/> </system.webServer> </configuration>
将WCF服务发布到Azure App Service之后,我可以创建服务引用。 一切正常,直到这里。
在调试期间,当我尝试在WCF服务中调用基本的“ GetData”功能时,它经常会请求用户凭据(如下图所示)。
我需要找到一种无需手动输入凭据即可访问我的Azure Web应用程序服务的方法。 我一直在努力解决这个问题。 似乎没有任何作用。
我必须问-您为什么选择在ASP.NET Web API(或任何其他现代RESTFul框架)上使用WCF? OAuth / JWT是云中现代服务用于安全性的工具。 API受可以在Azure AD中创建的客户端ID和密码保护。 我认为您不会在Azure中为WCF找到很多支持。 无论哪种方式,如果必须使用WCF,以下是将OAuth用于WCF的参考: OAuth和WCF SOAP服务
为了回答您的其他问题,Visual Studio使用发布配置文件将Web应用程序部署到Azure。 首次尝试从Visual Studio发布时,它将允许您导入发布配置文件。 您可以从Azure App Service的仪表板获取此信息,也可以将Visual Studio指向Azure中的App Service。 该对话框将为您提供保留凭据的选项。
您将为每种发布配置文件找到两种类型的文件:.pubxml文件和.pubxml.user文件。 对于Web Deploy和FTP发布,.pubxml.user文件包含加密形式的密码。 用户名可以在.pubxml文件中找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.