WCF Web服务移至Azure VM时出错

问题描述 投票:0回答:2

我有一个旧的WCF Web服务已被移动到Azure VM。

我可以在Azure中轻松访问:https://wcf/service.svc,但是当我尝试发布到:https://wcf/service.svc/json/DoAction时它会返回一个空响应,当我在浏览器中打开它时出现404错误。

在Azure之外它一切正常,任何想法我能做些什么来让它工作?我想让它在VM中运行,因为还有其他项目被移动并且工作正常。

以下是与“/ json /”部分相关的web.config文件的一部分:

<system.serviceModel>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  <services>
    <service name="Service123" behaviorConfiguration="ChallengeBehavior">
      <endpoint address="" binding="wsHttpBinding" bindingConfiguration="ChallengeMessageEncoding" contract="IService123" behaviorConfiguration="SoapServiceBehavior" />
      <endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestServiceMessageEncoding" contract="IService123" behaviorConfiguration="RestServiceBehavior" />
    </service>
  </services>
  <behaviors>
    <endpointBehaviors>
      <behavior name="RestServiceBehavior">
        <webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
      </behavior>
      <behavior name="SoapServiceBehavior">
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <bindings>
    <webHttpBinding>
      <binding name="RestServiceMessageEncoding">
        <security mode="None">
        </security>
      </binding>
    </webHttpBinding>
    <wsHttpBinding>
      <binding name="ChallengeMessageEncoding">
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" />
          <message clientCredentialType="None" establishSecurityContext="false" negotiateServiceCredential="false" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
</system.serviceModel>
azure wcf iis
2个回答
1
投票

在我看来,代码片段没有问题。 Azure VM中安装了哪个版本的IIS?您是否在IIS中启用了WCF支持的功能。 enter image description here 我怀疑在VM上发布的WCF服务无法正常工作。尝试发布默认的WCF服务应用程序项目并浏览自我介绍页面。 此外,对于特定端口,您需要在防火墙上启用出站/入站权限。

VM >>设置>>网络

如果有任何我可以帮助的话,请随时与我联系。


0
投票

@Abraham,谢谢你的回答。

我终于让它工作了,不知道哪个部分有帮助,但我介绍的变化包括:

a)安装了额外的WCF功能(如上所述),因为只安装了2个

b)在web配置中添加额外的位(允许在名称/Foo.svc/Save中运行带点的URL)

<handlers>
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  <clear />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="/*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

c)支持点的另一个配置:

<modules runAllManagedModulesForAllRequests="true" />

d)扩展端点以支持HTTPS,因为上面开始为HTTP工作:

  <service name="PrivateService" behaviorConfiguration="PrivateBehavior">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehavior" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehaviorSecure" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
    <endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestSecure" contract="IPrivateServices" behaviorConfiguration="RestBehavior" />
    <endpoint address="/json" binding="webHttpBinding" bindingConfiguration="Rest" contract="IPrivateService" behaviorConfiguration="RestBehavior" />
  </service>
  ...
  <webHttpBinding>
    <binding name="Rest">
      <security mode="None">
      </security>
    </binding>
    <binding name="RestSecure">
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None" />
      </security>
    </binding>
  </webHttpBinding>
© www.soinside.com 2019 - 2024. All rights reserved.