与多个端点的服务相同

问题描述:

我正在尝试创建一个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