简体   繁体   English

cosume webservice 应用程序上没有端点

[英]No endpoint on cosume webservice application

I am learning to create a WCF service.我正在学习创建 WCF 服务。 I tested my service that is worked when I tested it using SoapUi.我在使用 SoapUi 测试时测试了我的服务。 Now I am creating a testing website to add this service as service reference.现在我正在创建一个测试网站来添加这个服务作为服务参考。 When I call the method of the service, I got the error "Could not find default endpoint element that references contract".当我调用服务的方法时,出现错误“找不到引用合同的默认端点元素”。 I searched the web and still no idea to fix it.我在网上搜索,仍然不知道如何修复它。 Would someone help me what I should do or show me the example code.有人会帮助我我应该做什么或向我展示示例代码。 Thanks.谢谢。

There is my service config:有我的服务配置:

 <system.web>
   <compilation debug="true" targetFramework="4.5.2" />
   <authentication mode="Windows"/>
   <httpRuntime targetFramework="4.5.2"/>
 </system.web>
 <system.serviceModel>
    <services>
      <service behaviorConfiguration="ServiceBehaviour" name="Order.IOrders">
        <endpoint address="" binding="webHttpBinding"  contract="Order.IOrders" behaviorConfiguration="web">
        </endpoint>
      </service>
    </services>

    <behaviors>
       <serviceBehaviors>
        <behavior name="ServiceBehaviour">
        <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>
<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https"  />
 </protocolMapping>    
 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  <client>
  <endpoint
      name=""
      address="http://localhost:59837/Order.svc"
      binding="basicHttpBinding"
      contract="Order.IOrders" />
</client>
 </system.serviceModel>
 <system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
  <!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
   <directoryBrowse enabled="true"/>
</system.webServer>

The code in the client app:客户端应用程序中的代码:

 ServiceReference1.OrdersClient client = new ServiceReference1.OrdersClient();          
        client.checkOrderNumber(txtNum.Text.ToString());
    }

According to your description and code details, It seems that you want to invoke the WCF Service by adding service reference, you need to add WebHttpBehavior to the client endpoint.根据您的描述和代码细节,您似乎想通过添加服务引用来调用WCF Service,您需要将WebHttpBehavior添加到客户端端点。
You could refer to the following code.你可以参考下面的代码。

    <system.serviceModel>
      <behaviors>
        <endpointBehaviors>
          <behavior name="webEndpoint">
            <webHttp defaultBodyStyle="Wrapped"
                     defaultOutgoingResponseFormat="Xml"
                     helpEnabled="true"/>
          </behavior>
        </endpointBehaviors>
      </behaviors>
      <client>
        <endpoint name="myclient" address="http://localhost:9001/Service1.svc" binding="webHttpBinding" contract="ServiceReference1.IService1" behaviorConfiguration="webEndpoint"></endpoint>
      </client>
</system.serviceModel>

Feel free to let me know if there is anything I can help with.如果有什么我可以帮忙的,请随时告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM