首页 新闻 会员 周边

调用webservice时用代码进行配置

0
悬赏园豆:30 [待解决问题]

请问各位,我想调用webservice ,但是因为某种原因,我不能使用app.config配置WebService信息,也就是说我要在调用前写代码替换如下配置:

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="IUserInfoServiceHttpBinding" 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="">
                            <extendedProtectionPolicy policyEnforcement="Never" />
                        </transport>
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://192.168.1.118:7001/arsipWebService/service/IUserInfoService"
                binding="basicHttpBinding" bindingConfiguration="IUserInfoServiceHttpBinding"
                contract="UserInfoService.IUserInfoServicePortType" name="IUserInfoServiceHttpPort" />
        </client>
    </system.serviceModel>

请大家帮帮忙,谢谢了

 

HeartLight的主页 HeartLight | 初学一级 | 园豆:132
提问于:2012-08-01 09:46
< >
分享
所有回答(3)
0

这里有示例,用编码的方式绑定服务:http://www.cnblogs.com/artech/archive/2007/02/26/656901.html

artwl | 园豆:16736 (专家六级) | 2012-08-01 10:14
0

如果你是通过服务引用生成的客户端的话,那么你查阅下客户端的构造函数,你可以使用其中的一个重载方法来在代码中传入这些参数。

Launcher | 园豆:45045 (高人七级) | 2012-08-01 10:14
0

弄个动态创建的webservice来操作,不过要写代码,可以上网查查

az235 | 园豆:8483 (大侠五级) | 2012-08-01 10:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册