在https模式下执行我的wcf服务时显示错误消息 [英] showing error message while executing my wcf service in https mode
问题描述
嗨所有人......
这里面临问题,同时在https模式下使用wshttpBinding添加我的wcf ...我为我做了证书wcf服务使用这个链接
http:/ /msdn.microsoft.com/en-us/library/hh556232.aspx [ ^ ]
一旦通过此链接....你可以清楚地了解...发生了什么...
i为我的wcf服务创建了一个测试证书..
使用这个证书我wana运行我的wcf服务在htts:// localhost ....在SSL
这里我的
web.config文件
hi to all......
here am facing problem while adding my wcf in https mode with wshttpBinding... i make an certificate for my wcf service using this link
http://msdn.microsoft.com/en-us/library/hh556232.aspx[^]
once go through this link.... u can get clear idea.. what is going on...
i created a test certificate.. for my wcf service..
by using this certificate i wana run my wcf service in htts://localhost.... in SSL
here my
web.config file
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="samplewcf.Service1" behaviorConfiguration="samplewcf.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="https://localhost/samplewcf/Service.svc" binding="wsHttpBinding"
bindingConfiguration="TransportSecurity" contract="samplewcf.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="samplewcf.Service1Behavior" >
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://localhost/samplewcf/Service1.svc" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
让我知道任何修改...或者.. ppl检查我的代码..如果可能的话,修复它
let me know any modifications ... or.. ppl check my code.. and if possible fix it
推荐答案
我按照与MSDN链接相同的步骤添加证书。
然后我刚刚将绑定更改为https,如binding =mexHttpsBinding
,并在wshttpBinding
下添加了传输安全绑定。
这就是我所做的一切。它的运行。
配置中的问题是......
I followed the same steps as in the MSDN link to add a Certificate.
Then I just changed binding to https likebinding="mexHttpsBinding"
and added Transport security binding underwshttpBinding
.
That''s all I did. And its running.
The problems in your config are....
endpoint address="https://localhost/samplewcf/Service.svc"
httpsGetUrl="https://localhost/samplewcf/Service1.svc"
这些名称各不相同,一个是 Service.svc
,另一个是 Service1.svc
。
在两种情况下都写出正确的。
在这里使用相对地址,不是绝对的Url,正如我之前在上一个问题中建议的那样。
因此,如果web.config和Service位于同一个文件夹中,它们应该如下所示。
These names are varying, one is Service.svc
and other is Service1.svc
.
Write the correct one in both the cases.
And use Relative address here, not the absolute Url, as I suggested you before in the previous question.
So, they should look like below if the web.config and Service are in the same folder.
endpoint address="Service1.svc"
httpsGetUrl="Service1.svc"
所以,不要匆忙,小心翼翼地做。让我知道它是否解决了。
[更新]
配置文件如下所示,带下划线的项目需要根据您的项目进行验证和更改。
So, don''t be in a hurry and do it carefully. Let me know it solved or not.
[Update]
Config file is like below, underlined items need to verified and changed according to your project.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Ntitish_WcfService.Service1" behaviorConfiguration="Ntitish_WcfService.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="service.svc" binding="wsHttpBinding" contract="Ntitish_WcfService.IService" bindingConfiguration="TransportSecurity"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Ntitish_WcfService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="Service.svc"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
这篇关于在https模式下执行我的wcf服务时显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!