配置从C#代码中的Web服务端点和合同? [英] Configuring a web service endPoint and contract from C# code?

查看:110
本文介绍了配置从C#代码中的Web服务端点和合同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修改:我决定只将它转换为一个正常的网页,因为我只需要提供一个整型参数和检索字符串

Edit: I decided to just convert this to a normal web page, as I only need to provide one integer parameter and retrieve a string.

我会离开的问题开放,如果任何人有一个很好的答案。

I'll leave the question open if anyone has a good answer.


我有我想要调用Web服务,但因为这必须从插件到另一个系统,并在不会做所有的配置应用程序配置文件,作为插件系统被称为不读取该文件在一切,只是DLL。

I have a web service that I want to call, but because this must be called from a plugin to another system, an application config file with all the configuration in won't do, as the plugin system doesn't read that file at all, just the DLL.

所以,问题是,我怎么能采取从配置文件中的相关部分,并把这种代码呢?

So, the question is, how can I take the relevant parts from the config file and translate this to code instead?

我可能需要转换的部分是:

The parts I probably need to convert are:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="TooltipServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:2952/TooltipService.asmx"
            binding="basicHttpBinding" bindingConfiguration="TooltipServiceSoap"
            contract="TooltipService.TooltipServiceSoap" name="TooltipServiceSoap" />
    </client>
</system.serviceModel>



该网址,当然改变的这样的意愿,但是这对我来说,如果有人可以只点弄清楚我如何获得必要的代码到应用程序,这样,如果我删除应用程序配置文件,它仍然会工作的正确方向。

The URL and such will of course change, but that's for me to figure out if someone can just point me in the right direction on how to get the necessary code into the application so that if I delete the application config file, it will still work.

推荐答案

这是一个类似的问题,可能会帮助:使WCF更容易配置

This is on a similar issue and might help: Making WCF easier to configure

我想和几乎不需要客户端配置的应用程序 - 只需指向它在服务器并将其连接

I wanted to have an application with little or no client config required - just point it at the server and have it connect.

这篇关于配置从C#代码中的Web服务端点和合同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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