gpt4 book ai didi

c# - 找不到引用契约(Contract)的默认端点元素 - 托管 wcf

转载 作者:太空狗 更新时间:2023-10-30 00:02:55 32 4
gpt4 key购买 nike

我在这个站点上有一个 wcf 服务 http://wswob.somee.com/wobservice.svc

我尝试使用我的 winform 应用程序使用该服务。这是我在创建服务时收到的错误

com.somee.wobservice.IwobserviceClient myservice = new com.somee.wobservice.IwobserviceClient();

错误:

Could not find default endpoint element that references contract
'com.somee.wobservice.Iwobservice' in the ServiceModel client configuration section. This
might be because no configuration file was found for your application, or because no
endpoint element matching this contract could be found in the client element.

我搜索并修改了我的 app.config 文件:

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="wobservice">
<clientVia />
</behavior>
</endpointBehaviors>
</behaviors>

<client>
<endpoint
name="wobservice"
address="http://wswob.somee.com/wobservice.svc"
binding="webHttpBinding"
contract="com.somee.wobservice"
behaviorConfiguration="wobservice" />
</client>

</system.serviceModel>
</configuration>

还有我的 web.config 在 wcf 文件夹中:

<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>

<endpointBehaviors>
<behavior name="Web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://wswob.somee.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>

<bindings>
<webHttpBinding>
<binding>
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>

<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
<add binding="basicHttpBinding" scheme="http"/>
</protocolMapping>

<services>
<service name="wobwcf.wobservice">
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="Web"
contract="wobwcf.Iwobservice" />
</service>
</services>
</system.serviceModel>

我不太确定我错了哪一部分。我对wcf的体验才一周...

最佳答案

从您的库项目的 app.config 中复制 system.serviceModel 部分,并将其放入您的 web.config 并刷新服务引用。另请参阅此答案。 Could not find default endpoint element

关于c# - 找不到引用契约(Contract)的默认端点元素 - 托管 wcf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24050224/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com