[英]No endpoint on cosume webservice application
我正在学习创建 WCF 服务。 我在使用 SoapUi 测试时测试了我的服务。 现在我正在创建一个测试网站来添加这个服务作为服务参考。 当我调用服务的方法时,出现错误“找不到引用合同的默认端点元素”。 我在网上搜索,仍然不知道如何修复它。 有人会帮助我我应该做什么或向我展示示例代码。 谢谢。
有我的服务配置:
<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>
客户端应用程序中的代码:
ServiceReference1.OrdersClient client = new ServiceReference1.OrdersClient();
client.checkOrderNumber(txtNum.Text.ToString());
}
根据您的描述和代码细节,您似乎想通过添加服务引用来调用WCF Service,您需要将WebHttpBehavior添加到客户端端点。
你可以参考下面的代码。
<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>
如果有什么我可以帮忙的,请随时告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.