找不到引用合同的默认端点元素 - 托管wcf

Jac*_*hoi 4 c# hosting wcf winforms

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

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

com.somee.wobservice.IwobserviceClient myservice = new com.somee.wobservice.IwobserviceClient();
Run Code Online (Sandbox Code Playgroud)

错误:

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.
Run Code Online (Sandbox Code Playgroud)

我搜索并修改了我的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>
Run Code Online (Sandbox Code Playgroud)

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

<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>
Run Code Online (Sandbox Code Playgroud)

我不确定哪个部分出错了.我对wcf的体验只有一周......

小智 15

从库项目中的app.config复制system.serviceModel部分,并将其放在web.config和刷新服务引用中.另见这个答案.找不到默认端点元素