473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Submitting an Array to a Webservice.

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 ~


Nov 21 '05 #1
9 8251
"MMesich" <MM*****@discussions.microsoft.com> wrote in message news:F4**********************************@microsof t.com...
varOrder.ShipContact = "Abe Aberman"

' *** Problem comes here *** : : Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Initialize Items before assigning objects to it.

' Initialize Items array to an array containing 1 Item object.

Dim itemsArray As Item(1)
varOrder.Items = itemsArray

' Initialize Item object in each array slot (it is Nothing by default).

varOrder.Items(0) = New Item( )

: : varOrder.Items(0).sku = "SKU1"
varOrder.Items(0).qty = 5

: :
Derek Harmon
Nov 21 '05 #2
Still not quite there.

When I put in the line:

Dim itemsArray as Item(1)

I get an intellisense error stating "Array bounds cannot appear in type
specifiers."

If I remove the bound I can create a single Item but if I try to assign this
newly built item to varOrder.Items(0) I get an error to the effect that I
cannot convert the value of the Webform1.Item to the WS.Item object type.

Any further ideas?

~ Michael ~
"Derek Harmon" wrote:
"MMesich" <MM*****@discussions.microsoft.com> wrote in message news:F4**********************************@microsof t.com...
varOrder.ShipContact = "Abe Aberman"

' *** Problem comes here ***

: :
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.


Initialize Items before assigning objects to it.

' Initialize Items array to an array containing 1 Item object.

Dim itemsArray As Item(1)
varOrder.Items = itemsArray

' Initialize Item object in each array slot (it is Nothing by default).

varOrder.Items(0) = New Item( )

: :
varOrder.Items(0).sku = "SKU1"
varOrder.Items(0).qty = 5

: :
Derek Harmon

Nov 21 '05 #3
"MMesich" <MM*****@discussions.microsoft.com> wrote in message news:62**********************************@microsof t.com...
Dim itemsArray as Item(1)
I should just stick to C#.. OK, do this then,

Dim itemsArray(1) As Item

: : cannot convert the value of the Webform1.Item to the WS.Item object type.


I don't know what your Namespaces are. If you have an Item
(poor choice of class name in VB.NET, since it's also the name
of an indexer) in both Webform1 and WS, then fully-qualify the
type of Item as being from the WS namespace,

Dim itemsArray(1) As WS.Item
: :
varOrder.Items(0) = New Item( )


varOrder.items(0) = New WS.Item( )
Derek Harmon
Nov 21 '05 #4
I"m afraid this isn't working for me either. I still get "object not
instantiated" errors.

Can someone post a simple example of a webservice that uses a custom Class
with an array similar to my WSDL in the original post and show me the
client-side code to submit that array?

I can't wrap my head around this instantiation stuff.
Nov 21 '05 #5

Hi MMesich!!!
I really want to know if you get solve this problem 'cause I have
exactly the same problem...and I don't know what to do ...I've have
already look a lot of articles, sites, tutorial and I didn't find the
answer!!!

Please help me!!

tks a lot!

Rose

--
RoseIM
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1132804.html

Nov 23 '05 #6

RoseIM wrote:
*Hi MMesich!!!
I really want to know if you get solve this problem 'cause I have
exactly the same problem...and I don't know what to do ...I've have
already look a lot of articles, sites, tutorial and I didn't find the
answer!!!

Please help me!!

tks a lot!

Rose *


Rose,

Did you ever come up with a solution to this problem? I have the same
issue.

Rod

--
Rod Young
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1132804.html

Nov 23 '05 #7

RoseIM wrote:
*Hi MMesich!!!
I really want to know if you get solve this problem 'cause I have
exactly the same problem...and I don't know what to do ...I've have
already look a lot of articles, sites, tutorial and I didn't find the
answer!!!

Please help me!!

tks a lot!

Rose *


Rose,

Did you ever come up with a solution to this problem? I have the same
issue.

Rod

--
Rod Young
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1132804.html

Nov 23 '05 #8

Hi Rod!!!
I've found the solution!
You have to create an class with the structure of your array... an
instantiate it where you want to use...see...

Sorry for my English..
Rose
---CLASS-----

Imports System
Imports System.Web.Services

Namespace DataTypesVB.Enumerations

Public Class Sku
Public Sku As String
Public Qty As Integer
Public EndUserPrice As Double
End Class

End Namespace
---USING THE CLASS----

Dim oWsSku As DataTypesVB.Enumerations.Sku()

'numParc = number of rows
oWsSku = New DataTypesVB.Enumerations.Sku(numParc) {}

oWsSku(i) = New wsImla1.Sku
oWsSku(i).Sku1 = a
oWsSku(i).Qty = b
oWsSku(i).Price = c
oWsSku(i).EndUserPrice =
-
RoseI
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1132804.htm

Nov 23 '05 #9

Hi Rod!!!
I've found the solution!
You have to create an class with the structure of your array... an
instantiate it where you want to use...see...

Sorry for my English..
Rose
---CLASS-----

Imports System
Imports System.Web.Services

Namespace DataTypesVB.Enumerations

Public Class Sku
Public Sku As String
Public Qty As Integer
Public EndUserPrice As Double
End Class

End Namespace
---USING THE CLASS----

Dim oWsSku As DataTypesVB.Enumerations.Sku()

'numParc = number of rows
oWsSku = New DataTypesVB.Enumerations.Sku(numParc) {}

oWsSku(i) = New wsImla1.Sku
oWsSku(i).Sku1 = a
oWsSku(i).Qty = b
oWsSku(i).Price = c
oWsSku(i).EndUserPrice =
-
RoseI
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1132804.htm

Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
I am writing a webservice that has a method which requires an array of a custom object. I am having problems understanding why a few things are occuring My webservice looks like this ...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
1
by: Pim75 | last post by:
Hello, I've written a webservice that returns an array. The output of the webservice has to be consumed by a classic asp application. As classic asp can't read the returned array I want the...
1
by: carled | last post by:
Hi all. New here and new to .net from classic asp. I have to access an xml-rpc webservice in .net and it's making my brain fry trying to get it all set up. I'm most comfortable with vb, but I can...
1
by: gah | last post by:
I am getting an array of records from an asp.net webservice and wanting to display them in a dynamically created html table in the php page. I am new to php and not sure how to get the values from...
1
by: neoblitz | last post by:
Hi Guys, I'm very new to NuSoap. I'm able to call a webservice which actually returned me results.. But I'm having trouble to read the response or I simply don't understand how to read the response.....
2
by: ksheerasagar17 | last post by:
Hello All, Scenario: Sending an image through webservice as byte array to an Java webservice. The Problem1: The webservice method image property expects (data type) SByte rather than Byte...
0
by: David Wallace | last post by:
I had a lot of problems doing this, so when I finally got it to work, I thought I would share the wealth. I was really trying to pass a file from a Perl script to a C# web service, but it never...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.