创建具有多个端点的Web服务 [英] Create Web Service with multi endpoints

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

问题描述


我想创建包含两个绑定和两个合同的服务.
绑定是:
1. wsDualHttpBinding
2. wsHttpBinding

我有两个界面:
1.

Hi,
I want to create service that contains two binding and two contracts.
The binding are:
1. wsDualHttpBinding
2. wsHttpBinding

I get two interfaces:
1.

public interface IBasicSite<br />


2.


2.

public interface ISiteGateway:IBasicSite<br />


IBasicSite和ISiteGateway之间的区别仅在于ISiteGateway还支持Callback的ISiteGatewayCallback.
它们都使用相同的DataContracts.
这些类看起来像这样:


The difference between IBasicSite and ISiteGateway is only that ISiteGateway support also Callback''s that called ISiteGatewayCallback.
They both use same DataContracts.
The classes are looking like this:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]
    public class BasicSite : IBasicSite
{
...
}


而且SiteGateway看起来像这样:


And The SiteGateway look like this:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]public class SiteGateway : BasicSite, ISiteGateway
{
      List<ISiteGatewayCallback> callbackList = new List<ISiteGatewayCallback&gt;();
...
}


我的问题是如何配置服务.
这是我目前的配置:


My problem is how to configure the service.
this is my configuration for now:

<services>
 <service behaviorConfiguration="WcfService.SiteGatewayBehavior"

  name="WcfService.SiteGateway">
  <clear />
  <endpoint address="http://localhost:1189/SiteGateway" binding="wsDualHttpBinding"

   bindingConfiguration="" contract="WcfService.ISiteGateway">
   <identity>
    <dns value="localhost" />
    <certificateReference storeName="My" storeLocation="LocalMachine"

     x509FindType="FindBySubjectDistinguishedName" />
   </identity>
  </endpoint>
  <endpoint address="http://localhost:1189/BasicSite" binding="wsHttpBinding"

   bindingConfiguration="" contract="WcfService.IBasicSite" />
  <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"

   listenUriMode="Explicit">
   <identity>
    <dns value="localhost" />
    <certificateReference storeName="My" storeLocation="LocalMachine"

     x509FindType="FindBySubjectDistinguishedName" />
   </identity>
  </endpoint>
 </service>
</services


客户端能够看到这两个绑定并通过WSDL创建方法,但是当我使用它们时,我会遇到异常.
我的问题是:
1.客户端在尝试调用invoke时都会获得异常.
例如,当我在client2上使用此代码:


The client is able the see the two binding and create the methods by WSDL but when i use them i get an exception.
My problems are:
1. The client get an exception when ever he try to call invoke.
For example when ever i use this code:

BasicSiteClient bs = new BasicSiteClient();
bs.GotoPreset();

时,会得到以下异常:在收到对http://localhost:1189/BasicSite的HTTP响应时发生了错误.这可能是由于服务所致端点绑定未使用HTTP协议.这也可能是由于服务器终止了HTTP请求上下文(可能是由于服务已关闭).有关更多详细信息,请参阅服务器日志."
客户端尝试调用方法时.
2.我需要两个不同的
的DataContract相同 绑定将是相同的,因为其相同的类仅包含数据对象.
我在做什么错,应该如何解决这个问题?

谢谢,
Shai.

at the client2 i get this exception:"An error occurred while receiving the HTTP response to http://localhost:1189/BasicSite. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."
when ever the client try to call a method.
2. I need that the DataContract will be the same for the two different
binding will be the same because its the same class the contain only data objects.
What am i doing wrong and how should i solve this problems?

Thanks,
Shai.

推荐答案

这可能是由于超出maxBufferSize和/或maxReceivedMessageSize引起的.您可能想尝试在绑定配置设置中增加它们.
This could be caused by maxBufferSize and/or maxReceivedMessageSize being exceeded. You may want to try increasing them in your binding configuration settings.


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

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