WSDL creating and padding array into Object

Viewed 26

I'm trying to get away from stringbuilder SOAP requests and converting to using a WSDL document. Really trying to learn :)

I'm using a WSDL located at: production wsdl I'm making a rate request for freight. I have 2 commodity loads as follow commoditiy #1

class 60 weight 560 description Books

commoditiy #2 class 65 weight 230 description Used Books

I'm usein the FullCommoditiesType in the rate request itself.

The commodities are passed into an object termed "Item" which is part of the actual raterequest.

I'm having issues with assignment of the commodities to and array and passing it into the myrequest.item

FullCommoditiesType

I see in the FullCommoditiesType the "commodity" as FullCommodityType but can't get my head wrapped around how to construct the commodities into and array and pass it into the FullCommoditiesType.

I've been stuck on this for a loooong time (hours and hours) and would appreciate any help at all. I've googled lots of how to consume a WSDL and watch video's etc.

Thanks in advance :)

-dan

Right now I have

        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 FullCommodityType

    With myload1
        .class = (60)
        .weight = ("350")
        .description = ("Used Books-Magazines")
        .pieces = ("1")
        .pieceType = PackagingType.SK
    End With

    myrequest.Item = myload1

    Dim MyResponse As rateQuote = Nothing

    MyResponse = EstesRates.getQuote(myAuthorize, myrequest)

End Sub 
1 Answers

And the cure was

    Dim loaddata As New wsdl_estes.FullCommoditiesType
    Dim comList As New List(Of wsdl_estes.FullCommodityType)
    Dim com As wsdl_estes.FullCommodityType

    '1St commodity
    com = New wsdl_estes.FullCommodityType()
    com.class = 60
    com.description = ("Used Books")
    com.weight = ("1680")
    com.pieces = ("1")
    com.pieceType = PackagingType.SK
    com.dimensions = New wsdl_estes.DimensionsType()
    com.dimensions.length = ("42")
    com.dimensions.width = ("42")
    com.dimensions.height = ("36")
    comList.Add(com)

    loaddata.commodity = comList.ToArray()

    myrequest.Item = loaddata

My thanks to Jim who provided the answer

Related