繁体   English   中英

Windows 8 Store App和WCF服务

[英]Windows 8 Store App and WCF service

如果我尝试向空白Windows 8应用程序添加服务引用,则会出现以下两个警告/错误。

TransportSecurityBindingElement

该服务是带有ServiceName.svc文件的wcf服务,我已经看到一些带有ServiceName.asmx的服务。 这是原因吗? 我需要带有* .asmx文件的服务吗?

我真的很困惑,因为互联网上有太多关于这个主题的怪异内容。 同样令人困惑的是,它说不支持System.ServiceModel.Channels.TransportSecurityBindingElement,但是我从未使用过。 不在web.config或作为服务配置的代码中。

这是我在web.config中的服务配置:

<system.web>
  <compilation targetFramework="4.5" debug="true"/>
  <httpRuntime/>
  <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<diagnostics>
  <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"/>
</diagnostics>
<client/>
<services>
  <service behaviorConfiguration="basicHttpBehavior" name="e3kConnector.E3KConnectorService">
    <endpoint 
      address="mex" 
      binding="mexHttpBinding" 
      contract="IMetadataExchange" />
    <endpoint 
      address="" 
      binding="wsHttpBinding" 
      bindingConfiguration="wsHttpBinding"
      name="wsHttpEndpoint" 
      bindingName="" 
      contract="Service.MyService" />
    <endpoint 
      address="Soap" 
      binding="basicHttpBinding"
      bindingConfiguration="basicHttpBinding" 
      name="basicHttpBinding"
      bindingName=""
      contract="Service.MyService" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:50282/Service.svc" />
      </baseAddresses>
    </host>
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding" allowCookies="true">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Basic" proxyCredentialType="None" />
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </basicHttpBinding>
  <wsHttpBinding>
    <binding name="wsHttpBinding" allowCookies="true">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Basic" />
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="basicHttpBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="e3kConnector.App_Data.Security.CustomUserNameValidator,e3kConnector"/>
        <serviceCertificate findValue="tempCert" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
      </serviceCredentials>
      <serviceAuthorization principalPermissionMode="Custom">
        <authorizationPolicies>
          <add policyType="e3kConnector.App_Data.Security.AuthorizationPolicy, e3kConnector"/>
        </authorizationPolicies>
      </serviceAuthorization>
    </behavior>
  </serviceBehaviors>
</behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="false"/>
</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>

作为测试,我添加了这个tempConverter ,但这是可行的 (是的,我知道这是一个asmx文件。)我也知道svc和asmx之间的区别,但这就是为什么我感到困惑。 两者都支持SOAP,所以我仍然不明白为什么它不起作用。 也许很简单?

如果您需要更多详细信息,请告诉我。

这是因为Windows Store客户端应用程序仅支持WCF的小部分

在您的服务上尝试以下精简配置(删除了绑定wsHttp,行为和绑定配置):

<system.serviceModel>
  ....
  <services>
    <service name="e3kConnector.E3KConnectorService">
      <endpoint
        address="mex"
        binding="mexHttpBinding"
        contract="IMetadataExchange" />
      <endpoint
        address=""
        binding="basicHttpBinding"
        name="basicHttpBinding"
        contract="Service.MyService" />
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:50282/Service.svc" />
        </baseAddresses>
      </host>
    </service>
  </services>
  ....
</system.serviceModel>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM