C# Windows 8应用商店应用程序和WCF服务
如果我尝试向空白的windows 8应用程序添加服务引用,则会出现以下两个警告/错误 该服务是一个带有ServiceName.svc文件的wcf服务,我见过一些带有ServiceName.asmx的服务。这是原因吗?我需要带有*.asmx文件的服务吗 我真的很困惑,因为互联网上关于这个话题的东西太多了。 同样令人困惑的是,它说System.ServiceModel.Channels.TransportSecurityBindingElement不受支持,但我从未使用过它。不在web.config或“代码作为服务”配置中 下面是我在web.config中的服务配置:C# Windows 8应用商店应用程序和WCF服务,c#,wcf,web-services,visual-studio-2012,windows-store-apps,C#,Wcf,Web Services,Visual Studio 2012,Windows Store Apps,如果我尝试向空白的windows 8应用程序添加服务引用,则会出现以下两个警告/错误 该服务是一个带有ServiceName.svc文件的wcf服务,我见过一些带有ServiceName.asmx的服务。这是原因吗?我需要带有*.asmx文件的服务吗 我真的很困惑,因为互联网上关于这个话题的东西太多了。 同样令人困惑的是,它说System.ServiceModel.Channels.TransportSecurityBindingElement不受支持,但我从未使用过它。不在web.confi
<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>
,但这是可行的。(是的,我知道这是一个asmx文件。)
我也知道svc和asmx之间的区别,但这就是我感到困惑的原因。两者都支持SOAP,所以我仍然不明白它为什么不能工作。也许很简单
如果您需要更多详细信息,请告诉我。这是因为Windows应用商店客户端应用程序只支持一个
在您的服务上尝试此精简配置(已删除绑定wsHttp、行为和绑定配置):
....
....
忘记asmx——即.net 1.1和2.0服务,而不是WCF。任何3.0及以上版本都应该使用svcOk,谢谢。我现在使用的是.NET4.5,问题是如何让它工作:DSo当您尝试添加服务引用时,您是否遇到问题?该服务运行正常吗?是的,但仅适用于win8应用商店应用程序。WinForm应用程序工作没有任何问题。是的,它工作正常。谢谢因此,我需要为使用wsHttpBinding的其他客户端创建第二个服务?您可以尝试重新添加wsHttp端点,但给它一个地址限定符,如“wsHttp”或其他什么,它可能会工作。以前的问题可能是wshttp端点与您的基址是相同的URI,并且基本端点被称为“soap”。如果你改变了这一点,你的metro应用程序仍然可以工作,你的其他消费者也可以访问wshttp。值得一试,但wsdl中的额外内容可能会阻止metro的使用。好的,谢谢。我周一回到办公室后会试试这个:)
<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>