您的位置:首页 > 编程语言 > ASP

asp.net 调用带证书的webservice解决办法

2016-07-21 13:51 726 查看
最近在朋友弄一个调整省政府政务工作流的程序。。

需要把当前的信息推送到政务网上,采用的是带证书的https webservice。。

下面说一下实现过程

第一步,引用webservice地址,删除web.config中相关配置。同时安装好证书

用如下数据替换:

[html] view plain copy







<system.serviceModel>

<bindings>

<customBinding>

<binding name="IServiceSoapBinding" closeTimeout="00:01:00"

openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">

<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"

messageVersion="Soap11" writeEncoding="utf-8">

<!-- 政务大厅接口需要使用Soap11 -->

<readerQuotas maxDepth="32" maxStringContentLength="819200000" maxArrayLength="1638400000"

maxBytesPerRead="4096000" maxNameTableCharCount="16384000" />

</textMessageEncoding>

<httpsTransport manualAddressing="false" maxBufferPoolSize="52428800"

maxReceivedMessageSize="6553600" allowCookies="false" authenticationScheme="Anonymous"

bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

keepAliveEnabled="true" maxBufferSize="6553600" proxyAuthenticationScheme="Anonymous"

realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"

useDefaultWebProxy="true" requireClientCertificate="true" />

</binding>

</customBinding>

</bindings>

<client>

<endpoint address="https://WebService网址/CXFWebService/webservice/iservice" behaviorConfiguration="endpointBehavior1" binding="customBinding" bindingConfiguration="IServiceSoapBinding" contract="ZwdtServices.IService" name="ServiceImplPort" />

</client>

<behaviors>

<endpointBehaviors>

<behavior name="endpointBehavior1">

<dataContractSerializer maxItemsInObjectGraph="209715200"/>

<clientCredentials>

<clientCertificate findValue="证书用户" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>

<serviceCertificate>

<authentication certificateValidationMode="None"/>

<!--<defaultCertificate findValue="ShanXi Digital Certificate Authority" x509FindType="FindBySubjectName" storeLocation="CurrentUser" storeName="My"/>-->

</serviceCertificate>

</clientCredentials>

</behavior>

</endpointBehaviors>

</behaviors>

</system.serviceModel>

但在实际调用时,提示找不到对应的证书用户

我猜测可能是iis用户访问证书有关,那么就在用户和计算机上都导入证书。运行MMC,打开两个证书管理器,都把证书导入一次。

如图



完成之后,果然错误不一样。。

继续运行,出现没有权限的错误



继续设计证书权限

OK完成。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: