我想将我在Azure上运行的WCF服务从http
切换到https
,但是当我尝试从Windows Phone 7使用服务时,我得到了这个错误:
https://xxxxx.cloudapp.net/MainService.svc没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。
我创建了与服务uri同名的自签名证书,然后通过电子邮件将证书发送到Windows Phone并进行安装。但我不断收到这条消息,即使是从模拟器和真实手机也是如此。
消费服务同时适用于WPF和桌面Silverlight应用程序。
WP配置
ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IGEOService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential" />
</binding>
<binding name="BasicHttpBinding_IAccountService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxxxx.cloudapp.net/MainService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGEOService"
contract="ServiceReference1.IGEOService" name="BasicHttpBinding_IGEOService" />
<endpoint address="https://xxxxx.cloudapp.net/MainService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAccountService"
contract="ServiceReference1.IAccountService" name="BasicHttpBinding_IAccountService" />
</client>
</system.serviceModel>
在服务器上
clientaccesspolicy.xml
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://*" />
<domain uri="https://*" />
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
服务配置
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="Diplomka" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">
<Role name="MainWFCRole">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
<Certificates>
<Certificate name="diplomka.cloudapp.net" thumbprint="539B9A0149DC1221F0F4ECA79BAD84073BF1D650" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
<Role name="WebKlient">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
Serivce definiton
enter code here
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="Diplomka" xmlns="http://schemas.microsoft.com/ ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="MainWFCRole">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="https" port="443" certificate="diplomka.cloudapp.net" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
<LocalResources>
<LocalStorage name="MainWFCRole.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" />
</LocalResources>
<Certificates>
<Certificate name="diplomka.cloudapp.net" storeLocation="LocalMachine" storeName="My" />
</Certificates>
</WebRole>
<WebRole name="WebKlient">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
</WebRole>
web config
enter code here
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<services>
<service name="MainWFCRole.MainService" behaviorConfiguration="sb1">
<endpoint binding="basicHttpBinding" contract="MainWFCRole.IGEOService" bindingConfiguration="binding1"/>
<endpoint binding="basicHttpBinding" contract="MainWFCRole.IAccountService" bindingConfiguration="binding1"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<!--secure wcf by TransportWithMessageCredential security-->
<binding name="binding1">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="sb1">
<!---->
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MainWFCRole.AccountValidator,MainWFCRole"/>
</serviceCredentials>
<!--Enable https metadata exchange endpoint-->
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>