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

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

问题描述

编辑:我决定只将其转换为正常网页,因为我只需要提供一个整数参数并检索字符串。



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






我有一个Web服务想要调用,但是因为这必须从一个插件调用到另一个系统,一个应用程序配置文件与所有的配置都不会做,因为插件系统根本不读取该文件,只是DLL。 p>

所以,问题是,如何从配置文件中获取相关的部分,并将其转换为代码?



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

 < system.serviceModel> 
< bindings>
< basicHttpBinding>
< binding name =TooltipServiceSoapcloseTimeout =00:01:00openTimeout =00:01:00
receiveTimeout =00:10:00sendTimeout =00:01: 00allowCookies =false
bypassProxyOnLocal =falsehostNameComparisonMode =StrongWildcard
maxBufferSize =65536maxBufferPoolSize =524288maxReceivedMessageSize =65536
messageEncoding =TexttextEncoding =utf-8transferMode =Buffered
useDefaultWebProxy =true>
< readerQuotas maxDepth =32maxStringContentLength =8192maxArrayLength =16384
maxBytesPerRead =4096maxNameTableCharCount =16384/>
< security mode =None>
< transport clientCredentialType =NoneproxyCredentialType =None
realm =/>
< message clientCredentialType =UserNamealgorithmSuite =Default/>
< / security>
< / binding>
< / basicHttpBinding>
< / bindings>
< client>
< endpoint address =http:// localhost:2952 / TooltipService.asmx
binding =basicHttpBindingbindingConfiguration =TooltipServiceSoap
contract =TooltipService.TooltipServiceSoapname = TooltipServiceSoap/>
< / client>
< /system.serviceModel>

URL和这样的当然会改变,但这是我想知道,如果有人可以我在正确的方向上如何获得必要的代码到应用程序,以便如果我删除应用程序配置文件,它仍然可以工作。

解决方案

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



我想要一个应用程序,只需要很少或不需要客户端配置 - 只需将其指向服务器并连接。


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.


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.

解决方案

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服务endPoint和合同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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