1

我过去在 VB.net 中开发过,但我根本不知道如何正确调用此函数以及如何获取响应,以便将其显示在网页响应中。

我将示例 c# 代码翻译成 VB。这是我希望用来发出请求然后在我的页面中显示响应的 aspx 页面背后的代码:

Imports OffAmazonPaymentsService
Imports OffAmazonPaymentsService.Model

Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Write(GetOrderReferenceDetails(???service???, "asdfsadf", "asdfsadf", "asdfasdf"))

    End Sub
    Private Shared Function GetOrderReferenceDetails(service As IOffAmazonPaymentsService, sellerId As String, amazonOrderReferenceId As String, addressConsentToken As String) As GetOrderReferenceDetailsResponse
        ' Required parameters
        Dim request As New GetOrderReferenceDetailsRequest()
        request.SellerId = sellerId
        request.AmazonOrderReferenceId = amazonOrderReferenceId

        ' Optional parameters
        request.AddressConsentToken = addressConsentToken

        Return service.GetOrderReferenceDetails(request)
    End Function
End Class

我不知道如何调用该函数的第一个(服务)参数,然后显示响应的内容。

如果我的问题不够清楚,请告诉我。这是他们以升c格式给出的示例....

using OffAmazonPaymentsService;
using OffAmazonPaymentsService.Model;

public class GetOrderReferenceDetailsSample
{
    /**
     * Sample GetOrderReferenceDetails method that takes generic inputs, constructs a request object,
     * and make a call to the service.
     */
    private static GetOrderReferenceDetailsResponse GetOrderReferenceDetails(
        IOffAmazonPaymentsService service,
        string sellerId,
        string amazonOrderReferenceId,
        string addressConsentToken)
    {
        // Required parameters
        GetOrderReferenceDetailsRequest request = new GetOrderReferenceDetailsRequest();
        request.SellerId = sellerId;
        request.AmazonOrderReferenceId = amazonOrderReferenceId;

        // Optional parameters
        request.AddressConsentToken = addressConsentToken;

        return service.GetOrderReferenceDetails(request);
    }
}
4

1 回答 1

0

免责声明:我的 VB 是“生锈的”,所以需要调试和改进

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        Dim props As OffAmazonPaymentsServicePropertyCollection = OffAmazonPaymentsServicePropertyCollection.getInstance()
        Dim client As New OffAmazonPaymentsServiceClient(props)
        Dim result as GetOrderReferenceDetailsResponse = GetAmzOrderRef(client, props, "oref", "token")

End Sub


Private Shared Function GetAmzOrderRef(service As IOffAmazonPaymentsService, props As OffAmazonPaymentsServicePropertyCollection, amazonOrderReferenceId As String, addressConsentToken As String) As GetOrderReferenceDetailsResponse

        Dim request as New GetOrderReferenceDetailsRequest()
        With request
            .SellerId = props.MerchantID
            .AmazonOrderReferenceId = amazonOrderReferenceId
            .AddressConsentToken = addressConsentToken
        End With
        Return service.GetOrderReferenceDetails(request)

End Function

笔记:

  • 你应该设置你的configweb.configapp.config根据需要),这就是OffAmazonPaymentsServicePropertyCollection.getInstance()获取值的地方

  • 由于参考 id 和令牌的虚拟值,上述示例代码将失败(如预期的那样),但“错误”来自 Amazon API(已经) - 例如响应错误“无效参考 id”或“无效令牌”等。 ..

嗯……

于 2015-12-02T15:06:20.163 回答