简体   繁体   English

Windows 8 Store App和WCF服务

[英]Windows 8 Store App and WCF service

If I try to add a service reference to my blank windows 8 app, I've got following two warnings/errors. 如果我尝试向空白Windows 8应用程序添加服务引用,则会出现以下两个警告/错误。

TransportSecurityBindingElement

The service is a wcf service with a ServiceName.svc file, i've seen some services wit a ServiceName.asmx. 该服务是带有ServiceName.svc文件的wcf服务,我已经看到一些带有ServiceName.asmx的服务。 Is this the cause? 这是原因吗? Does I need a service with an *.asmx file? 我需要带有* .asmx文件的服务吗?

I'm really confused because there is too much and wirde stuff on the internet for this topic. 我真的很困惑,因为互联网上有太多关于这个主题的怪异内容。 Also confusing is, it says that System.ServiceModel.Channels.TransportSecurityBindingElement is not supported, but I never used this. 同样令人困惑的是,它说不支持System.ServiceModel.Channels.TransportSecurityBindingElement,但是我从未使用过。 Not in web.config or in the code as service configuration. 不在web.config或作为服务配置的代码中。

Here my service configuration in 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>

As test I added this tempConverter , but this works. 作为测试,我添加了这个tempConverter ,但这是可行的 (Yes I know it's an asmx file.) I know also the difference between svc and asmx, but thats why I'm confused. (是的,我知道这是一个asmx文件。)我也知道svc和asmx之间的区别,但这就是为什么我感到困惑。 Both supports SOAP, so I still don't get it why it won't work. 两者都支持SOAP,所以我仍然不明白为什么它不起作用。 Maybe it's very simple? 也许很简单?

If you need more details please let me know. 如果您需要更多详细信息,请告诉我。

This is happening because Windows Store client apps support only a small subset of WCF . 这是因为Windows Store客户端应用程序仅支持WCF的小部分

Try this slimmed down config on your service (removed binding wsHttp, behavior and binding configs): 在您的服务上尝试以下精简配置(删除了绑定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