无法添加服务。可能无法访问服务元数据。确保您的服务正在运行并公开元数据。 [英] Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.

查看:92
本文介绍了无法添加服务。可能无法访问服务元数据。确保您的服务正在运行并公开元数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友



以下是我在.net4 webservice项目中的web配置文件



<结构> 

< system.web>
< compilation debug =truetargetframework =4.0/>
< /system.web>
< system.servicemodel>
< bindings>
< basichttpbinding>
< binding name =Basic/>
< / basichttpbinding>
< / bindings>
< services>
< service behaviorconfiguration =NewBehaviorname =MyserviceLibrary1.Myservice>
< endpoint address =http:// http:// localhost:20437 / Service2.svc>
binding =basicHttpBindingbindingConfiguration =Basicname =Basic
contract =MyserviceLibrary1.IMyservice/>

< / endpoint>< / service>
< / services>
< behavior>
< servicebehaviors>
< behavior name =>
< servicemetadata httpgetenabled =true/>
< servicedebug includeexceptiondetailinfaults =false/>
< / behavior>
< behavior name =NewBehavior>
< servicemetadata httpgetenabled =true/>
< / behavior>
< / servicebehaviors>
< / behavior>
< servicehostingennultiplesitebindingsenabled =true/>
< /system.servicemodel>
< system.webserver>
< modules runallmanagedmodulesforallrequests =true/>
< /system.webserver>

< / configuration>



如何解决此错误。

解决方案

您应首先检查是否可以连接并浏览该服务。


在我的情况下,我通过在web.config中将aspNetCompatibilityEnabled设置为false来修复它。


将此添加到您的配置





  <  行为 >  
< servicebehaviors >
< 行为 name = metadataBehavior >
< servicemetadata httpgetenabled = true / >
< / behavior >
< / servicebehaviors >
< / behavior >
< 服务 >
< service name = MyService.MyService behaviorconfiguration = metadataBehavior >
< 端点 >
address =<! - 不要在这里放任何东西 - 卡西尼将确定地址 - >
binding =basicHttpBinding
contract =MyService.IMyService/>
< endpoint >
address =mex
binding =mexHttpBinding
contract =IMetadataExchange/>
< / endpoint > < / endpoint > < / service >
< / services >


Hi friends

the following is my web config file in .net4 webservice project

<configuration>

  <system.web>
    <compilation debug="true" targetframework="4.0" />
  </system.web>
  <system.servicemodel>
    <bindings>
      <basichttpbinding>
        <binding name="Basic" />
      </basichttpbinding>
    </bindings>
    <services>
      <service behaviorconfiguration="NewBehavior" name="MyserviceLibrary1.Myservice">
        <endpoint address="http://http://localhost:20437/Service2.svc">
          binding="basicHttpBinding" bindingConfiguration="Basic" name="Basic"
          contract="MyserviceLibrary1.IMyservice" />
        
      </endpoint></service>
    </services>
    <behaviors>
      <servicebehaviors>
        <behavior name="">
          <servicemetadata httpgetenabled="true" />
          <servicedebug includeexceptiondetailinfaults="false" />
        </behavior>
        <behavior name="NewBehavior">
          <servicemetadata httpgetenabled="true" />
        </behavior>
      </servicebehaviors>
    </behaviors>
    <servicehostingenvironment multiplesitebindingsenabled="true" />
  </system.servicemodel>
 <system.webserver>
    <modules runallmanagedmodulesforallrequests="true" />
  </system.webserver>
  
</configuration>


how can solve this error.

解决方案

You should first check if you can connect and browse the service.


In my case I fixed it by setting aspNetCompatibilityEnabled to "false" in web.config


Add this to your config


<behaviors>
   <servicebehaviors>
      <behavior name="metadataBehavior">
         <servicemetadata httpgetenabled="true" />
      </behavior>
   </servicebehaviors>
</behaviors>
<services>
   <service name="MyService.MyService" behaviorconfiguration="metadataBehavior">
      <endpoint>
          address=""   <!-- don't put anything here - Cassini will determine address -->
          binding="basicHttpBinding" 
          contract="MyService.IMyService"/>
      <endpoint>
          address="mex" 
          binding="mexHttpBinding" 
          contract="IMetadataExchange"/>
   </endpoint></endpoint></service>
</services>


这篇关于无法添加服务。可能无法访问服务元数据。确保您的服务正在运行并公开元数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆