簡體   English   中英

配置WCF服務服務器端以接受Mtom

[英]Configure WCF service server side to accept Mtom

我是Web服務的新手,我正在嘗試配置WCF服務以使用Visual WCF服務模板從另一個服務中提取文件。

我設法拉除內容數據之外的所有內容。 我搜索后發現,必須使用Mtom而不是Text進行消息編碼。 問題是我不確定如何配置我的Web服務以使用MessageEncoding = Mtom。 我擺弄了web.config文件,但似乎無法正確配置它。

這是我的服務界面

 [ServiceContract]
public interface IService
{

    [OperationContract]
    string test(changeData data);
    [OperationContract]
    RetrieveChangeListResponse GetChangeList();
    [OperationContract]
    RetrieveChangeTaskListResponse GetTaskList();
    [OperationContract]
    RetrieveInteractionAttachmentResponse GetFile(string id);

    // TODO: Add your service operations here
}

這是我的web.config

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttp" allowCookies="true"
             maxReceivedMessageSize="20000000"
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000"
             messageEncoding ="Mtom">
      <readerQuotas maxDepth="32"
           maxArrayLength="200000000"
           maxStringContentLength="200000000"/>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="IService"
           behaviorConfiguration="ServiceWithMetadata">
    <endpoint name="BasicHttpBinding_IService"
              binding="basicHttpBinding"
              bindingConfiguration="basicHttp"
              contract="IService" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceWithMetadata">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

當前,如果使用此設置,則會出現此錯誤:

錯誤:無法從localhost:50282 / Service.svc獲取元數據。如果這是您有權訪問的Windows(R)Communication Foundation服務,請檢查是否已在指定地址啟用元數據發布。 有關啟用元數據發布的幫助,請參閱URI上的MSDN文檔:localhost:50282 / Service.svc元數據包含無法解析的引用:“ localhost:50282 / Service.svc”。 內容類型application / soap + xml; 服務localhost:50282 / Service.svc不支持charset = utf-8。 客戶端和服務綁定可能不匹配。 遠程服務器返回錯誤:(415)由於內容類型為'application / soap + xml,因此無法處理該消息; charset = utf-8'不是預期的類型'text / xml; charset =utf-8'。HTTPGET錯誤URI:localhost:50282 / Service.svc HTML文檔不包含Web服務發現信息。

如果刪除這些設置,則會得到如下類型的不匹配:

客戶發現響應內容類型為“多部分/相關”; 類型= “文本/ xml” 的; boundary =“ ---- = _ Part_0_30957184.1421681490926””,但應為'text / xml'。

我知道有一個針對WcfTestClient的配置和一個針對實際服務的配置,但是我不了解如何正確配置服務器端以正確接受Mtom編碼。

有人可以解釋如何正確配置服務器端綁定嗎? 我使用BasicHttpBinding ,但也想將wshHttpBinding用於soap 1.2功能。

提前致謝。

問題出在所使用的身份驗證方法中,我使用的是匿名名稱而不是基本名稱。 同樣,您不能擁有作為代理數據類型的方法返回類型。 如果您有這樣的方法,您將得到有關類派生的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM