[英]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.