473,804 Members | 3,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:Envelop e xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">
<soap:Body>
<OrderSubmit xmlns="http://tempuri.org/WebServices/beta">
<varCustNum>str ing</varCustNum>
<varPassword>st ring</varPassword>
<Order>
<Terms>string </Terms>
<ShipContact />
<ShipAddress1>s tring</ShipAddress1>
<ShipAddress2>s tring</ShipAddress2>
<ShipCity>strin g</ShipCity>
<ShipZip>string </ShipZip>
<ShipState>stri ng</ShipState>
<Items>
<Item>
<sku>string</sku>
<qty>string</qty>
<location>strin g</location>
<shipvia>string </shipvia>
</Item>
<Item>
<sku>string</sku>
<qty>string</qty>
<location>strin g</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.Custom erNumber = "340000v"
varOrder.Passwo rd = "pass1"
varOrder.Terms = "N30"
varOrder.ShipAd dress1 = "123 Anystreet"
varOrder.ShipAd dress2 = "Suite ABC"
varOrder.ShipCi ty = "Anytown"
varOrder.ShipSt ate = "GA"
varOrder.ShipZi p = "55555"
varOrder.ShipCo ntact = "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.NullRefe renceException: 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"
[NullReferenceEx ception: Object reference not set to an instance of an
object.]
OrderEntryTestP age.WebForm1.Pa ge_Load(Object sender, EventArgs e) in
c:\inetpub\wwwr oot\OrderEntryT estPage\WebForm 1.aspx.vb:61
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()
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 8271
"MMesich" <MM*****@discus sions.microsoft .com> wrote in message news:F4******** *************** ***********@mic rosoft.com...
varOrder.ShipCo ntact = "Abe Aberman"

' *** Problem comes here *** : : Exception Details: System.NullRefe renceException: 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*****@discus sions.microsoft .com> wrote in message news:F4******** *************** ***********@mic rosoft.com...
varOrder.ShipCo ntact = "Abe Aberman"

' *** Problem comes here ***

: :
Exception Details: System.NullRefe renceException: 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*****@discus sions.microsoft .com> wrote in message news:62******** *************** ***********@mic rosoft.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.Serv ices

Namespace DataTypesVB.Enu merations

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.Enu merations.Sku()

'numParc = number of rows
oWsSku = New DataTypesVB.Enu merations.Sku(n umParc) {}

oWsSku(i) = New wsImla1.Sku
oWsSku(i).Sku1 = a
oWsSku(i).Qty = b
oWsSku(i).Price = c
oWsSku(i).EndUs erPrice =
-
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.Serv ices

Namespace DataTypesVB.Enu merations

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.Enu merations.Sku()

'numParc = number of rows
oWsSku = New DataTypesVB.Enu merations.Sku(n umParc) {}

oWsSku(i) = New wsImla1.Sku
oWsSku(i).Sku1 = a
oWsSku(i).Qty = b
oWsSku(i).Price = c
oWsSku(i).EndUs erPrice =
-
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
2443
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 namespace WSTes /// <summary /// Summary description for Service1 /// </summary dfl
7
4990
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 Parameter. I can call the first Method without Problems, the Parameter can be deserialized by the WebService. But if I want to call the second Method and give it an Array of Parameters, then the following exception is thrown by the WebService:...
5
19604
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 having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
1
1541
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 webservice to return a xml document instead of the array. Can anyone tell me how I can output the array as a xml document?
1
2000
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 translate from c# if anyone can do it in that! I have created a class in my app_code folder that will access the webservice like so: Imports Microsoft.VisualBasic Imports CookComputing.XmlRpc Public Class mapserver Public Structure...
1
1594
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 the array. I get an "invalid argument error in for each" error message. If I run the program and inspect the $res, I can see all the records in the TMemberListRec. I tried to use TMemberListRec in the for each to access them, but still get an...
1
10022
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.. here is the code i've used to call the service. It returns a kind of big array so i'm so much lost inside it.. I would be grateful if someone help me out on reading the array values into variables so that i can do something depends on the result...
2
9791
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 array. Thus i'm converting a byte array to sbyte array and sending through web service. The converted SByte contains negative numbers wihch are resulting in an error "java.lang.ArrayIndexOutOfBoundsException: -106" Byte => SByte...error...
0
7328
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 worked. The best I could do was passing the contents of the file as an array, and even that was no picnic. So you need to install Perl, and then the Soap::Lite package. I am working in both AIX and Windows. Compose a Perl script ( myscript.pl )...
0
9587
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.