WCF服务解析器错误,无法从命名空间“http://tempuri.org/”导入绑定“xxx”

时间:2012-01-10 20:09:57

标签: wcf iis-7

我有一个WCF服务我试图在我的服务器上的IIS中运行。但是,我不知道如何处理这个错误,我在搜索谷歌时发现的每个修复都没有用。我在这里缺少什么?

错误消息:无法从名称空间“http://tempuri.org/”导入绑定“...”。

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="MyService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true">
      <assemblies>
        <add assembly="Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="MyServiceBinding">
          <security mode="Message">
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="MyService">
        <endpoint binding="wsHttpBinding" behaviorConfiguration="webHttp" contract="MyService">
          <identity>
            <dns value="https://IPADDRESS:443"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webHttp">
          <webHttp defaultOutgoingResponseFormat="Json" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="WCFWsHttpBindingHttps.MyServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

 <applicationSettings>
  <MyService.Properties.Settings>
   <setting name="MyService_MyOtherService_MyOtherService" serializeAs="String">
    <value>http://path-to-service/MyOtherService.svc</value>
   </setting>
  </MyService.Properties.Settings>
 </applicationSettings>
</configuration>

[edit]我应该注意到,在我从IIS引用该服务时,我在我引用的DIFFERENT服务上遇到错误。它命中WSDL的第1行并抛出解析错误。

1 个答案:

答案 0 :(得分:1)

只看你的web.config

  • 服务名称和合同是相同的,尽管可能不是最佳做法
  • 服务名称应该是完全限定的(包含名称空间)
  • 您定义的服务行为未被您的服务元素引用(应添加behaviorConfiguration="WCFWsHttpBindingHttps.MyServiceBehavior"
  • 您应该设置serviceDebug includeExceptionDetailInFaults="true",以便获得正确的错误消息。