无法添加 Azure 中托管的 WCF 服务



我在服务器上托管了一个 WCF 服务

http://firstdomain.com/WebStorePrice/PickStorePrice.svc

它在我的机器上运行。现在我将其托管到新服务器作为 azure 服务,当尝试添加服务引用时,我收到错误

下载"https://service.azurewebsites.net/PickStorePrice.svc/$metadata"时出错。 请求失败,HTTP 状态为 404:未找到。 元数据包含无法解析的引用:"https://service.azurewebsites.net/PickStorePrice.svc"。 没有终结点侦听可以接受消息的 https://service.azurewebsites.net/PickStorePrice.svc。 这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在(。 远程服务器返回错误:(404( 未找到。 如果服务是在当前解决方案中定义的,请尝试生成解决方案并再次添加服务引用。 WCF 服务的 Webconfig 看起来像

<system.serviceModel>
<services>
<service name="WebStorePrice.PickStorePrice" behaviorConfiguration="cstmServiceConfig">
<endpoint address="" binding="basicHttpBinding" contract="WebStorePrice.IPickStorePrice"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="secure">
<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="cstmendpointConfig">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="cstmServiceConfigOnline">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="cstmServiceConfig">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

从服务配置来看,我们的服务不支持Https协议Azure因为默认情况下 docker(Paas( 服务器通过 Https 进行通信。因此,我们应该配置一个额外的服务终结点来支持基于 https 的 WCF。
对于 Soap 风格的 Web 服务,请参考以下配置。

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
<add binding="basicHttpBinding" scheme="http"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

关于WCF宁静风格的服务。

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="mybinding">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add binding="webHttpBinding" scheme="http"/>
<add binding="webHttpBinding" scheme="https" bindingConfiguration="mybinding"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

如果问题仍然存在,请随时告诉我。

最新更新