【问题标题】:Error in Calling/Fetching wcf service调用/获取 wcf 服务时出错
【发布时间】:2013-07-10 10:02:24
【问题描述】:

我有这样的方法

<OperationContract()>
<Web.WebGet(UriTemplate:="/GetBedTypeList?strErrMsg={strErrMsg}&chrErrFlg={chrErrFlg}&pcompanycode={pcompanycode}&pdiv={pdiv}&ploc={ploc}", ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Wrapped)> _
Function GetBedTypeList(ByRef strErrMsg As System.Collections.Generic.List(Of String), ByRef chrErrFlg As Char, _
                        ByVal pcompanycode As String,ByVal pdiv As Integer, _
                        ByVal ploc As Integer) As System.Collections.Generic.List(Of CWReadClasses.clsBedTypeMaster)

但报错请帮忙

合约“iBedTypeMaster”中的操作“GetBedTypeList”有一个名为“strErrMsg”的查询变量,类型为“System.Collections.Generic.List1[System.String]', but type 'System.Collections.Generic.List1[System.String]”,不能由“QueryStringConverter”转换。 UriTemplate 查询值的变量必须具有可由“QueryStringConverter”转换的类型。

【问题讨论】:

    标签: wcf


    【解决方案1】:

    正如错误所述,默认情况下,WCF 不知道如何将查询字符串参数(它是一个字符串)转换为 List(Of String),这是您的 strErrMsg 参数的类型。您可以将其更改为已知类型(字符串、数字、布尔值),也可以按照错误提示将QueryStringConverter 添加到您的服务中,以“教”它如何从查询字符串转换为该类型.您可以在http://blogs.msdn.com/b/carlosfigueira/archive/2011/08/09/wcf-extensibility-querystringconverter.aspx 的帖子中找到有关查询字符串转换器的更多信息。

    【讨论】:

      猜你喜欢
      • 2015-12-29
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 2010-12-11
      • 2016-09-25
      • 2021-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多