在WCF服务相对URL绑定 [英] relative url in wcf service binding

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

问题描述

我有一个Silverlight控件具有基准来一个Silverlight的WCF服务。

I have a silverlight control which has a reference to a silverlight enabled wcf service.

当我引用添加到我的Silverlight控件的服务,它增加了以下我clientconfig文件:

When I add a reference to the service in my silverlight control, it adds the following to my clientconfig file:

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_DataAccess" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:3097/MyApp/DataAccess.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_DataAccess"
                contract="svcMyService.DataAccess" name="BasicHttpBinding_DataAccess" />
        </client>
    </system.serviceModel>
</configuration>

我如何指定端点地址,而不是绝对URL相对URL?我希望它的工作无论我在哪里部署web应用程序,而无需编辑clientconfig文件,因为Silverlight组件和Web应用程序将始终部署在一起。我想我能够指定只是DataAccess.svc,但它似乎不喜欢这样。

How do I specify a relative url in the endpoint address instead of the absolute url? I want it to work no matter where I deploy the web app to without having to edit the clientconfig file, because the silverlight component and the web app will always be deployed together. I thought I'd be able to specify just "DataAccess.svc" but it doesn't seem to like that.

推荐答案

您不能使用在客户端的端点配置相对URI。你可以做的仅仅是添加另一个构造你的代理类,将采取某种形式的URL参数,你可以或许得到另一个配置值或使用的DN类方法之一。

You can't use relative URIs in client endpoint configuration. What you can do is just add another constructor to your proxy class that will take some sort of URL parameter that you can perhaps get from another config value or use one of the Dns class methods.

这篇关于在WCF服务相对URL绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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