2010-05-25 46 views
7

我一直在嘗試將舊的WSE 3 Web服務移植到WCF。由於保持與WSE 3客戶的向後兼容性是我的目標,因此我遵循article中的指導。嘗試將Web引用添加到WCF服務的HTTP 400錯誤請求錯誤

大量的試驗和錯誤後,我可以從我WSE 3客戶端調用WCF服務。但是,我無法從Visual Studio 2005(安裝WSE 3)添加或更新對此服務的Web引用。響應是「請求失敗,HTTP狀態400:錯誤請求」。嘗試使用wsewsdl3實用程序生成代理時出現同樣的錯誤。我可以添加使用VS 2008

我試着用同樣的結果在Windows 7和Windows 2008 R2服務器託管在IIS 7.5的服務的服務參考。任何解決方案或故障排除建議

下面是我的WCF服務配置文件中的相關章節。

<system.serviceModel> 
    <services> 
     <service behaviorConfiguration="MyBehavior" 
     name="MyService"> 
     <endpoint address="" binding="customBinding" bindingConfiguration="wseBinding" 
      contract="IMyService" /> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 

    <bindings> 
     <customBinding> 
     <binding name="wseBinding"> 
      <security authenticationMode="UserNameOverTransport" /> 
      <mtomMessageEncoding messageVersion="Soap11WSAddressingAugust2004" /> 
      <httpsTransport/> 
     </binding> 
     </customBinding> 
    </bindings> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceCredentials> 
      <userNameAuthentication userNamePasswordValidationMode="Custom" 
       customUserNamePasswordValidatorType="MyCustomValidator" /> 
      </serviceCredentials> 
      <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="MyRoleProvider" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    </system.serviceModel> 

UPDATE:試圖保羅的追蹤建議之後,我已經確定的例外是System.Xml.XmlException:消息的身體無法閱讀,因爲它是空

不幸的是,這似乎沒有太大的幫助。我注意到的另一件事是,serviceMetadata元素有一個單獨的httpsGetEnabled屬性。我添加了它,並將其設置爲true,因爲這是一項https服務,但結果相同。看起來由於某種原因WCF沒有意識到這是一個元數據請求。

+0

當你輸入IE中的WSDL URL,你看到了嗎?如果您添加VS 2010的參考,它是否工作? – 2011-08-12 23:16:43

回答

2

你可以嘗試啓用WCF服務器上跟蹤。插入此</system.serviceModel>行:

<diagnostics> 

    <messageLogging 
    logEntireMessage="true" 
    logMalformedMessages="true" 
    logMessagesAtServiceLevel="true" 
    logMessagesAtTransportLevel="false" 
    maxMessagesToLog ="3000" /> 

</diagnostics> 

插入此</system.serviceModel>行:

<system.diagnostics> 
    <sharedListeners> 
     <add name="sharedListener" 
      type="System.Diagnostics.XmlWriterTraceListener" 
      initializeData="c:\logs\tracelog.svclog" /> 
    </sharedListeners> 
    <sources> 
     <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing" > 
      <listeners> 
       <add name="sharedListener" /> 
      </listeners> 
     </source> 
     <source name="System.ServiceModel.MessageLogging" switchValue="Verbose"> 
      <listeners> 
       <add name="sharedListener" /> 
      </listeners> 
     </source> 
     <source name="ApplicationLogging" switchValue="Information" > 
      <listeners> 
       <add name="sharedListener" /> 
      </listeners> 
     </source> 
    </sources> 
</system.diagnostics> 

您複製錯誤後,開始WCF tracing tool並打開日誌文件。可能會發生一些異常。

- 編輯 -

那麼,這是一個有趣的錯誤消息。它會導致更多的谷歌搜索結果:

  1. Another stackoverflow question
  2. Could be fixed in next release of Windows 7
  3. TransferMode.StreamedResponse