从VB.NET Web表单调用我的第一个WCF服务中的函数会引发错误。函数调用缺少WCF函数中的参数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从VB.NET Web表单调用我的第一个WCF服务中的函数会引发错误。函数调用缺少WCF函数中的参数相关的知识,希望对你有一定的参考价值。

我刚刚编写了我的第一个WCF服务,事情看起来非常顺利,直到我需要在VB.NET Web表单中使用该服务。服务中的Function声明是:

Public Function ProcessCCPaymentAuthorizeDotNet(InvoiceID As String, Description As String, CustomerID As String, CardNumber As String, ExpirationDate As String, _
    CVV As String, Price As String, FirstName As String, LastName As String, Address As String, State As String, Zip As String, CompanyName As String, BillingCity As String, _
    BillingState As String, BillingZip As String, Login As String, TranKey As String, MD5Hash As String, AuthorizeURL As String, ByRef ResponseReasonCode As Integer, _
    ByRef ResponseReasonText As String) As Integer Implements IService1.ProcessCCPaymentAuthorizeDotNet

我得到的错误是:

Argument not specified for parameter 'ProcessCCPaymentAuthorizeDotNetResult' of 'Public Sub ProcessCCPaymentAuthorizeDotNet(InvoiceID As String, Description As String, CustomerID As String, CardNumber As String, ExpirationDate As String, CVV As String, Price As String, FirstName As String, LastName As String, Address As String, State As String, Zip As String, CompanyName As String, BillingCity As String, BillingState As String, BillingZip As String, Login As String, TranKey As String, MD5Hash As String, AuthorizeURL As String, ByRef ResponseReasonCode As Integer, ByRef ResponseReasonCodeSpecified As Boolean, ByRef ResponseReasonText As String, ByRef ProcessCCPaymentAuthorizeDotNetResult As Integer, ByRef ProcessCCPaymentAuthorizeDotNetResultSpecified As Boolean)'

我很好奇ResponseReasonCodeSpecified,ProcessCCPaymentAuthorizeDotNetResult和ProcessCCPaymentAuthorizeDotNetResultSpecified甚至来自它们,因为它们不在供应给服务调用的参数列表中。我敢肯定这是一个菜鸟的错误。任何帮助是极大的赞赏!

答案

您要么不调用函数ProcessCCPaymentAuthorizeDotNet,要么ProcessCCPaymentAuthorizeDotNet函数调用具有相同名称但签名不同的其他方法。尽管如此,在堆栈的某个地方,另一个版本被调用,并且未传递预期的参数。您可以通过查看方法的签名与错误消息中提供的签名来判断它们的名称相同但方法不同。最大的问题是你的版本是一个函数,错误信息是Sub。

我推荐stepping through the code with the debugger。请记住,您始终可以包含try catch并查看异常的StackTrace属性,以帮助您确定代码失败的位置。

另一答案

我通过将<OperationContract()>更改为<OperationContract(), XmlSerializerFormat(Style:=OperationFormatStyle.Document)>来解决我的问题。

再次感谢您的回复。

麦克风

以上是关于从VB.NET Web表单调用我的第一个WCF服务中的函数会引发错误。函数调用缺少WCF函数中的参数的主要内容,如果未能解决你的问题,请参考以下文章

在我的 Web 应用程序引用的类库中访问 wcf 数据服务时出现问题

从 wcf 服务调用第三方 Web 服务

无法从本地机器调用 WCF 服务

无法从本地机器调用 WCF 服务

从 Android 客户端调用 Web 服务

从 WCF 服务调用 Web API 端点