调用非.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还略慢一点.

转载于:https://www.cnblogs.com/zitjubiz/archive/2011/09/27/WCF_Soap_Header.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值