簡體   English   中英

代理的生成在一種環境中工作正常,但在另一種環境中卻行不通?

[英]Generation of proxy works fine in one environment but not in the other?

我在Windows Service(Selfhost)中托管了一個簡單的Webserivce(WCF)。 服務的聲明如下所示:

<service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
        <endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8008/MyAppServiceutv/Integration"/>
          </baseAddresses>
        </host>
      </service>

我可以使用以下URL瀏覽WSDL:

http://localhost:8008/MyAppServiceutv/Integration?wsdl

在Visual Studio 2012中添加服務引用時,出現此異常:

例外

該文檔已被理解,但無法處理。

  • WSDL文檔包含無法解析的鏈接。
  • 下載' http://localhost:8008/MyAppServiceutv/Integration?xsd=xsd0 '時http://localhost:8008/MyAppServiceutv/Integration?xsd=xsd0
  • 無法連接到遠程服務器

元數據包含無法解析的引用:' http://MyComputer:8008/MyAppServiceutv/Integration?wsdl '。 內容類型application / soap + xml; 服務http://MyComputer:8008/MyAppServiceutv/Integration?wsdl不支持charset = utf-8。 客戶端和服務綁定可能不匹配。 遠程服務器返回錯誤:(415)由於內容類型為'application / soap + xml,因此無法處理該消息; charset = utf-8'不是預期的類型'text / xml; charset = utf-8'。如果服務在當前解決方案中定義,請嘗試構建解決方案並再次添加服務引用。

遷移到開發環境

將服務移至開發計算機時,一切工作正常嗎? 為什么在一個環境中誰會遇到上述問題? 這可能是由於強大的安全限制所致嗎?

聽起來您的VS2012實例已從服務主機關閉。 嘗試像這樣更改您的配置...

  <service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
    <endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://{my fully qualified domain name}:8008/MyAppServiceutv/Integration"/>
      </baseAddresses>
    </host>
  </service>

好的。 現在,我已經確認了問題……是一個解釋。 .net 4.0或更低版本WCF會生成多文件WSDL文件。 基本WSDL文件鏈接到各種文件。 WDSL文件中的鏈接使用絕對URI(而不是相對URI)鏈接到其他文件。 因此,當您的Visual Studio嘗試查找其他WDSL文件時,它將無法在“ localhost”上找到它。

使用.net 4.5,WCF可以生成“單文件WSDL”,這也可以解決您的問題。 但是總的來說,我認為在處理WSDL代理生成時WCF 4.0已損壞。

暫無
暫無

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

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