c# 调用Web Service的问题:The operation 'XXX' could not be loaded because it has a parameter...

问题描述:

c# 引用webservice ,在执行调用过程中:

QTMIntegrationService.WebServiceQTMSoapClient client = new HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoapClient();
client.QTMIntegrationService(xmldoc.InnerXml, machinetype, testtype);

调用时,提示: The operation 'getSoapAsync' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.


系统异常日志:

-----------------------------异常信息 Start-----------------------------
当前时间:2015-05-23 12:00:33
异常消息:The operation 'QTMIntegrationServiceAsync' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.
异常对象:System.ServiceModel
调用堆栈:at System.ServiceModel.Dispatcher.OperationFormatter.Validate(OperationDescription operation, Boolean isRpc, Boolean isEncoded)
   at System.ServiceModel.Dispatcher.OperationFormatter..ctor(OperationDescription description, Boolean isRpc, Boolean isEncoded)
   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter..ctor(OperationDescription description, DataContractFormatAttribute dataContractFormatAttribute, DataContractSerializerOperationBehavior serializerFactory)
   at System.ServiceModel.Description.DataContractSerializerOperationBehavior.GetFormatter(OperationDescription operation, Boolean& formatRequest, Boolean& formatReply, Boolean isProxy)
   at System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
   at System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch)
   at System.ServiceModel.Description.DispatcherBuilder.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime)
   at System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters)
   at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
   at System.ServiceModel.ChannelFactory.CreateFactory()
   at System.ServiceModel.ChannelFactory.OnOpening()
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ChannelFactory.EnsureOpened()
   at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.ChannelFactory`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoapClient.HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoap.QTMIntegrationService(QTMIntegrationServiceRequest request) in d:\Visual Studio 2012\HLQTMIntegration\HLTestSyncIntegration\Service References\QTMIntegrationService\Reference.cs:line 131
   at HLTestSyncIntegration.QTMIntegrationService.WebServiceQTMSoapClient.QTMIntegrationService(String strxml, String machineType, String testType) in d:\Visual Studio 2012\HLQTMIntegration\HLTestSyncIntegration\Service References\QTMIntegrationService\Reference.cs:line 140
   at HLTestSyncIntegration.TestSyncService.HandlelabQTM() in d:\Visual Studio 2012\HLQTMIntegration\HLTestSyncIntegration\TestSyncService.cs:line 185
触发方法:Void Validate(System.ServiceModel.Description.OperationDescription, Boolean, Boolean)
-----------------------------异常信息 End-----------------------------

开发环境:Win7 64位,.NET 4.5,VS2012

运行环境:Win7 32位,.NET 4.0

问题原因:开发环境有4.5,运行环境没有,导致的问题。安装了.NET 4.5 ,问题解决。


原文地址:http://q.cnblogs.com/q/72045/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值