I'm fried on this problem...It's vb.net, dealing with a web service
that requires input as an array of a particular data structure and I
can't get the code to compile or run...
Basically, the webservice is showing me the following:
Public structure A
public a1 as string
end structure
Public structure B
public b1 as string
public b2 as string
end structure
Public structure RequestStructur e
public PartA as A
public PartB() as B
end structure
Public structure ResponseStructu re
public ok as string
end structure
<webrequest()Pu blic Function DoStuff(byval RequestStructur e as
RequestStructur e) as ResponseStructu re
So, I have the following code:
dim myA as new com.xxx.xxx.xxx .etc.A
myA.a1="Test"
dim myRequestStruct ure as new com.xxx.xxx.xxx .etc.RequestStr ucture
myRequestStruct ure.PartA=myA
(so far, so good)
dim myB(10) as new com.xxx.xxx.xxx .etc.B
results in a syntax error "Arrays cannot be declared with new". Ok, so
I'll take out "new". It compiles, but, I then get an "object reference
not set to an instance of an object" error later on when I attempt to
put data into myB.
So, I changed the dim to:
dim myB as arraylist
and then, each time I put something in, I put it in as a structure in
the form of structure B.
But, that creates a problem when I get to the actual web service call,
since I cannot say:
MyRequestStruct ure.PartB=MyB
because MyB is an arraylist, not of type B. There probably is a way to
make this work, by pulling out the individual items in the arraylist,
but I've tried several dozen seemingly clever ways to assign the data
to MyRequestStruct ure.PartB and it either doesn't pass syntactically,
or it blows up with an "object reference..." error.
So, I figured I'd create my own, local, structure containing the B
structure from the webservice. That doesn't work, since I can't assign
my local structure to myRequestStruct ure.PartB because they are
technically 2 different types.
So, I figured I'd create a local structure containing the B structure
inside it. That's basically the same as the ArrayList solution, and
has the same problems.
I thought "createinstance " would be the solution, but I haven't had
any success in getting that to work with a structure defined in a web
service.
I've looked all over the place trying to find ANY example of anyone
ever passing a structure and have found NONE. Surely, someone has done
this without brute-force coding it as discrete xml instead of a soap
call...
And, I have NO control over the webservice at the other end.
Craig
Comment