问题描述
我在此站点上有一项wcf服务 http://wswob.somee.com/wobservice.svc
I have one wcf service on this site http://wswob.somee.com/wobservice.svc
我尝试通过Winform应用程序使用该服务.这是我创建服务即时消息
I try to consume that service with my winform app. This is the error I receive when I create an instant of the service
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文件:
I searched and modified my app.config file:
<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>
在wcf文件夹中还有我的web.config:
And my web.config in wcf folder:
<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的体验只有一个星期...
I don't really sure which part I got wrong. My experience of wcf is just a week...
推荐答案
从库项目中的app.config复制system.serviceModel部分,并将其放入web.config中并刷新服务参考.另请参阅此答案. 找不到默认端点元素
Copy system.serviceModel section from the app.config in your library project and put it in your web.config and refresh service reference. See also this answer. Could not find default endpoint element
这篇关于找不到引用合同的默认端点元素-托管WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!