I've got an order entry webservice whose WSDL looks like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<OrderSubmit xmlns="http://tempuri.org/WebServices/beta">
<varCustNum>string</varCustNum>
<varPassword>string</varPassword>
<Order>
<Terms>string</Terms>
<ShipContact />
<ShipAddress1>string</ShipAddress1>
<ShipAddress2>string</ShipAddress2>
<ShipCity>string</ShipCity>
<ShipZip>string</ShipZip>
<ShipState>string</ShipState>
<Items>
<Item>
<sku>string</sku>
<qty>string</qty>
<location>string</location>
<shipvia>string</shipvia>
</Item>
<Item>
<sku>string</sku>
<qty>string</qty>
<location>string</location>
<shipvia>string</shipvia>
</Item>
</Items>
</Order>
</OrderSubmit>
</soap:Body>
</soap:Envelope>
This WSDL is auto-generated from these class definitions:
Public Class OrderResult
Public ErrorMessage As String
Public Status As String
End Class
Public Class Order
' *** Reseller Info ***
Public Terms As String
' *** Customer Shipping Information ***
Public ShipContact as string
Public ShipAddress1 As String
Public ShipAddress2 As String
Public ShipCity As String
Public ShipZip As String
Public ShipState As String
'*** Detailed Item Array ***
Public Items As Item()
End Class
Public Class Item
Public sku As String
Public qty As Integer
Public location As String
Public shipvia As String
End Class
So my problem is how do I fill the array of Items? I must be missing some
funky Array parameter or something. I try this from a client ASPX file:
Dim varOrder As New WS.Order '** Instantiate Webservice Object
varOrder.CustomerNumber = "340000v"
varOrder.Password = "pass1"
varOrder.Terms = "N30"
varOrder.ShipAddress1 = "123 Anystreet"
varOrder.ShipAddress2 = "Suite ABC"
varOrder.ShipCity = "Anytown"
varOrder.ShipState = "GA"
varOrder.ShipZip = "55555"
varOrder.ShipContact = "Abe Aberman"
' *** Problem comes here ***
varOrder.Items(0).sku = "SKU1"
varOrder.Items(0).qty = 5
varOrder.Items(0).location = "ATL"
varOrder.Items(0).shipvia = "UPS"
Intellisense supports the code above just fine. But when executed I get:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 59:
Line 60: 'Dim tstItems As Items
Line 61: varOrder.Items(0).sku = "SKU1" <<---- Highlighted line
Line 62: varOrder.Items(0).qty = 5
Line 63: varOrder.Items(0).location = "ATL"
[NullReferenceException: Object reference not set to an instance of an
object.]
OrderEntryTestPage.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\OrderEntryTestPage\WebForm1.asp x.vb:61
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
I've tried working with creating an array locally and then setting the
webservice array equal to it but I'm having a heck of a time even with that.
Anyone out there have experience with Class Arrays and what I'm missing to
get it submissible to my little webservice?
Thanks in advance!
~ Michael ~