• 调用非.net系统的Webservice的探索 ( 三 ) WCF


    WCF的模型和之前.net的WS有所不同. 你在添加Service Reference生成的代理类可以看到

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel""4.0.0.0")]
    public partial class MathServiceClient : System.ServiceModel.ClientBase<IMathService>, IMathService {}

     而WCF著名的"ABC"

     

    而我们这里调用java系统的WebService,只需要处理Address和Binding

    来看看生成的app.config内容,留意黄色高亮的,是我们手工添加修改的.

    <configuration>
        <system.serviceModel>
            <bindings>            
                <customBinding>
                    <binding name="IDrmServiceSoapHttp">
                        <security authenticationMode="UserNameOverTransport" 
                                  allowInsecureTransport="true" includeTimestamp="false">
                        </security>
                         <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                            messageVersion
    ="Soap11" writeEncoding="utf-8">
                            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                                maxBytesPerRead
    ="4096" maxNameTableCharCount="65536" />
                        </textMessageEncoding>
                        <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                            maxReceivedMessageSize
    ="65536" allowCookies="false" authenticationScheme="Anonymous"
                            bypassProxyOnLocal
    ="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
                            keepAliveEnabled
    ="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                            realm
    ="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                            useDefaultWebProxy
    ="true" />
                    </binding>
                </customBinding>
                
            </bindings>
            <client>
                
                <endpoint address="http://localhost:8080/oracle-epm-drm-webservices/DrmService"
                    binding
    ="customBinding" bindingConfiguration="IDrmServiceSoapHttp"
                    contract
    ="DRM.IDrmService" name="DrmServicePortType" >
                    <headers>
                        <AppParameters xmlns="http://drm.webservices.epm.oracle">
                            <serverUrl>http://DRMServer:5240/Oracle/Drm/APIAdapter</serverUrl>
                            <sessionParams>ProductVersion=11.1.2.1</sessionParams>
                        </AppParameters>
                    </headers>
                </endpoint>
                
            </client>
        </system.serviceModel>
    </configuration>

     调用方法如下:

    MathServiceClient svc = new MathServiceClient();
                svc.ClientCredentials.UserName.UserName = "MyUserName";
                svc.ClientCredentials.UserName.Password = "MyPassword";         

           label1.Text =svc.Add(12);               

    WCF整个使用方法对比起WSE就简单很多了.

    但作为客户端来说,我粗略测试了性能, 和WSE差不多,WCF还略慢一点.

  • 相关阅读:
    现代软件工程 第一章 【概论】第8题——原旭莹,张晓丽
    现代软件工程 第一章 【概论】第2题——孙雪莹
    现代软件工程 第一章 【概论】第11题——原旭莹
    现代软件工程 第一章 【概论】第6题——原旭莹
    现代软件工程 第一章 【概论】第9题——孙雪莹
    现代软件工程 第一章 【概论】第7题——原旭莹
    现代软件工程 第一章 【概论】第12题——张晓丽
    现代软件工程 第一章 【概论】第5题——原旭莹
    现代软件工程 第一章 【概论】第4题——张功
    [Python]conda与 virtualenv虚拟环境配置
  • 原文地址:https://www.cnblogs.com/zitjubiz/p/WCF_Soap_Header.html
Copyright © 2020-2023  润新知