zoukankan      html  css  js  c++  java
  • 调用非.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还略慢一点.

  • 相关阅读:
    jdk环境变量配置
    Oracle常用操作命令
    Oracle数据库突然宕机,处理方案
    Oracle重启操作步骤
    大家好,我是一名程序员,这就是2017年的我……
    Oracle恢复删除数据
    网络爬虫
    第一篇博客
    函数(二)
    MFC(二)
  • 原文地址:https://www.cnblogs.com/zitjubiz/p/WCF_Soap_Header.html
Copyright © 2011-2022 走看看