繁体   English   中英

使用相同绑定的WCF客户端和服务端点

[英]WCF Client and Service Endpoints Using the Same Binding

我觉得这可能已经回答了,也许我没有用正确的术语进行搜索。

我有一个像代理一样的WCF服务。 这是两个通常可以互相交流的服务的中间人,但现在可以通过这项新服务。

老:A - > B.

新:A - > MM - > B.

我需要公开与服务端点相同的合同(“A”与“MM”对话)和客户端点(“MM”与“B”对话)。

这两个可以共享绑定配置,只是给端点不同的名称? 或者有更好的方法来处理这种情况吗?

(在<system.serviceModel>标签内)

<client>
    <endpoint address="http://<remoteaddress>/" binding="basicHttpBinding" 
    bindingConfiguration="MyBinding" contract="IService" name="ToB" />
</client>
<services>
    <service behaviorConfiguration="Behavior" name="Service">
        <endpoint address="" binding="basicHttpBinding"
        bindingConfiguration="MyBinding" name="FromA" contract="IService" />
        <host>
            <baseAddresses>
                <add baseAddress="http://localhost:8080/MyService" />
            </baseAddresses>
        </host>
    </service>
</services>
<bindings>
    <basicHttpBinding>
        <binding name="MyBinding" closeTimeout="00:15:00" openTimeout="00:15:00"
        receiveTimeout="00:15:00" sendTimeout="00:15:00" allowCookies="false" 
        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferSize="2048000000" maxBufferPoolSize="2048000000" 
        maxReceivedMessageSize="2048000000" messageEncoding="Text" 
        textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" 
            maxArrayLength="4065536" maxBytesPerRead="4096" 
            maxNameTableCharCount="16384" />
            <security mode="None">
                <transport clientCredentialType="None" 
                proxyCredentialType="None" realm="" />
                <message clientCredentialType="UserName" 
                algorithmSuite="Default" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>

编辑:

此设置的错误消息是:

com.vsp.cal.webservice.external.SystemFault

堆栈:服务器堆栈跟踪:

   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

名称的更改不足以唯一地定义端点。 而是回到旧的“ABC” - 地址,约束,合同。 其中至少有一个必须不同才能唯一地定义新端点。 http://msdn.microsoft.com/en-us/library/ms733107(v=vs.100).aspx

这有帮助吗?

感谢所有看过这个并试图提供帮助的人!

最后,它不是配置,而是一个愚蠢的编码错误。 隐秘的错误消息是来自另一方的响应(Java Web服务)。 它不高兴,因为我因为失败的演员而发送了一个空对象。

所以答案是,当你不像白痴一样编码时,这种配置会起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM