我有一個內置於.NET 4.0的WCF Web服務,該服務被配置爲每次調用時都需要用戶名/密碼,並在行爲中使用服務器證書來加密請求。它目前使用wsHttpBinding。我有一個.NET 4實用程序應用程序,可以讓我調用此WCF Web服務上的方法。如何從.NET類庫調用WCF服務
我需要從.NET 2.0類庫調用此服務。該庫在VS 2010中,但是面向.NET 2.0--我想簡單地切換到.NET 4.0,但不能出於政治原因和時間限制。因此,現在使用的wsHttpBinding和服務器證書已不存在我讀過的內容。
從閱讀的點點滴滴,我做了以下內容:
- 改變了結合使用 basicHttpBinding的 從行爲
- 安裝,並在類 啓用WSE服務器證書的
- 刪除提圖書館 項目。
- 嘗試在.NET 2.0 winforms應用程序中使用WCF Web服務方法 - 史詩般失敗!
無論如何我似乎在服務器端配置綁定HTTPS只是不可接受;唯一的方法就是讓它來讓我調用它,就是使用「None」的安全模式,grrrghhh!這當然讓我叫它但隨後的用戶名/密碼信息不提供,永遠不會對WCF服務設置,因此當它最終試圖保存,因爲用戶ID爲0
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false"/>
<services>
<service name="MyService.NameHere" behaviorConfiguration="NameOfMyConfigHere">
<endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding" contract="DirectoryServices.IDirectorySubmitService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehaviourName">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicBinding" maxReceivedMessageSize="5242880">
<readerQuotas maxStringContentLength="5242880"/>
<security mode="None">
<transport clientCredentialType="Basic" proxyCredentialType="Basic" />
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
失敗如果任何人都能幫我弄清楚正確的魔術放在哪裏,我會非常感激。
我想要做的就是調用提供用戶名/密碼的WCF Web方法,並使用SSL進行加密。該服務正在IIS上運行。客戶端是一個winforms應用程序。
Errmm,無論我的帖子是不明確的,或者你沒有理解它。 Web服務是WCF,並且正在.NET 4.0上的「服務器」上運行。桌面應用程序是.NET 2.0,只需通過SSL調用帶有用戶名/密碼的服務即可。整個互聯網上的許多帖子都表示,這可能只是沒有足夠的細節。 – Peter 2010-11-01 08:47:13
我不確定這是可能的彼得。一般來說,.NET 2.0客戶端並不知道如何使用Web服務。也許有辦法做到這一點,但我認爲這將是相當黑客。 – Bernard 2010-11-01 13:20:16