2010-05-25 42 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