与多个端点的服务相同 [英] Same service to multiple Endpoints

查看:90
本文介绍了与多个端点的服务相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个Web服务,它将同时提供Ajax调用(JSON)和C#形式的应用程序调用。我理解我需要的端点,并且可以让它们单独工作,但是我不能让它们同时工作时间。



首先我试过这个:

I am trying to create a web service that will serve both Ajax calls (JSON) and C# form Application calls.I understand the endpoints i need and can get both to work individually, however i cannot get them to work at the same time.

First i tried this:

<services>
      <service name="MyWebService.Service" behaviorConfiguration="WebServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="MyWebService.IService" behaviorConfiguration="JsonBehaviour">
          <identity>
            <dns value="ServerName"/>
          </identity>
        </endpoint>        <endpoint address="" binding="basicHttpBinding" contract="MyWebService.IService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>



然后我进展到:


I then progressed to this:

<services>
      <service name="MyWebService.Service" behaviorConfiguration="WebServiceBehaviour">
       <endpoint address="" binding="basicHttpBinding" contract="MyWebService.IService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      <service name="MyWebService.Service" behaviorConfiguration="WebServiceBehaviour">

        <endpoint address="" binding="webHttpBinding" contract="MyWebService.IService" behaviorConfiguration="JsonBehaviour">
          <identity>
            <dns value="ServerName"/>
          </identity>
        </endpoint> 
 </service>
</services>



这些尝试都没有奏效,现在我被强迫了。我正在努力做什么?


Neither of these attempts worked, and now i am compeltely stumped. Is what i am trying to do even possible?

推荐答案

您好,

您需要为您的服务创建多个绑定和端点。

看看

--Avinash
Hi ,
You need to create multiple bindings and endpoints for your service.
Have a look
--Avinash


这篇关于与多个端点的服务相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆