You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Estes的WSDL运费查询接口如何将商品数组赋值给rateRequest的Item属性

解决方案

你需要按以下逻辑调整代码即可解决问题:

  1. FullCommoditiesType的commodity字段本身就是FullCommodityType数组类型,先创建包含2件商品的数组赋值给该字段
  2. rateRequest的Item属性接收的是FullCommoditiesType对象,不是单个商品对象

修改后的完整代码如下:

Dim myAuthorize As New wsdl_estes.AuthenticationType
Dim myrequest As New wsdl_estes.rateRequest()
Dim EstesRates As ratingPortTypeClient = New ratingPortTypeClient
Dim pickup As New wsdl_estes.PointType
Dim delivery As New wsdl_estes.PointType

With myAuthorize
    .user = ("myuser")
    .password = ("myPwd")
End With

With myrequest
    .account = ("xxxxxx")
    .payor = ("S")
    .terms = ("P")
End With

With pickup
    .city = ("Knoxville")
    .stateProvince = ("TN")
    .postalCode = ("37918")
    .countryCode = ("USA")
End With

With delivery
    .city = ("Knoxville")
    .stateProvince = ("TN")
    .postalCode = ("37918")
    .countryCode = ("USA")
End With

myrequest.originPoint = pickup
myrequest.destinationPoint = delivery

' 构造商品集合容器
Dim loaddata As New wsdl_estes.FullCommoditiesType()

' 构造第一件商品
Dim myload1 As New wsdl_estes.FullCommodityType
With myload1
    .class = 60
    .weight = "560"
    .description = "Books"
    .pieces = "1"
    .pieceType = PackagingType.SK
End With

' 构造第二件商品
Dim myload2 As New wsdl_estes.FullCommodityType
With myload2
    .class = 65
    .weight = "230"
    .description = "Used Books"
    .pieces = "1"
    .pieceType = PackagingType.SK
End With

' 将两个商品存入数组,赋值给loaddata的commodity属性
loaddata.commodity = New wsdl_estes.FullCommodityType() {myload1, myload2}

' 把完整的商品集合赋值给request的Item属性
myrequest.Item = loaddata

Dim MyResponse As rateQuote = Nothing
MyResponse = EstesRates.getQuote(myAuthorize, myrequest)
End Sub

内容的提问来源于stack exchange,提问作者dashley

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 05:42:03