PC Review


Reply
Thread Tools Rate Thread

Call a web service that returns a struct

 
 
Andrew
Guest
Posts: n/a
 
      13th Apr 2009
I am trying to access a web service method (that was written in C#) which
returns a structure. I am programming my side in VB.Net.

So the c# struct looks like:
public struct mystruc {
public string result;
public int error;
}

This is what I have in my code, or more to the point, what I have
figured out that works:
Dim xSvc As some.server.WebService
Dim gString As String = xSvc.mystruct().result

So, the question is how do I return the structure into an object (using only
one call) which will allow me to access each of the structures values.
Something like this for example:

Dim xSvc As some.server.WebService
Dim gOB As Object = xSvc.mystruct()

gString = gOB.Result
dError = gOB.Error


I can't seem to find any info on this?


 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      14th Apr 2009
"Andrew" <(E-Mail Removed)> wrote in message
news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
>I am trying to access a web service method (that was written in C#) which
> returns a structure. I am programming my side in VB.Net.
>
> So the c# struct looks like:
> public struct mystruc {
> public string result;
> public int error;
> }
>
> This is what I have in my code, or more to the point, what I have
> figured out that works:
> Dim xSvc As some.server.WebService
> Dim gString As String = xSvc.mystruct().result
>
> So, the question is how do I return the structure into an object (using
> only
> one call) which will allow me to access each of the structures values.
> Something like this for example:
>
> Dim xSvc As some.server.WebService
> Dim gOB As Object = xSvc.mystruct()
>
> gString = gOB.Result
> dError = gOB.Error
>
>
> I can't seem to find any info on this?
>
>


It would need to be a known XML serialized object returned from the XML Web
service in order for you to cast the object back to a known object type.

You can't use Object because that is a generic object, and even a generic
Object would have to be cast to a known type object for you to address any
properties or methods of the known object type.

The only way you can use it without it being a known object on the client
side would also include that the Web service send it back as a known object
on the Web service side, where as, you can use a "var" on the client side.

I'll assume that "var" can be used in VB like it can be used in C#.

var myobject = xSvc.someWebserviceMethod -- the Web service method returned
a known serialized object on its side to the client.

Then you can do gString = myobject.Result and gError = myobject.Error, if
those are the two properties being sent back for the object sent by the XML
Web service.

If an object is not being sent back by the Web service, then it's going to
the XML that is sent back where it would be a known xsd for the XML that
you would use to address on the client side for Result and Error tags.

That's how things work, and you can't make it up on the client side. The
client side has to know what is coming back from the Web service side, and
then you can do with it what ever you want to after you get it and address
it.



 
Reply With Quote
 
Andrew
Guest
Posts: n/a
 
      14th Apr 2009

"Mr. Arnold" wrote:

> "Andrew" <(E-Mail Removed)> wrote in message
> news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
> >I am trying to access a web service method (that was written in C#) which
> > returns a structure. I am programming my side in VB.Net.
> >
> > So the c# struct looks like:
> > public struct mystruc {
> > public string result;
> > public int error;
> > }
> >
> > This is what I have in my code, or more to the point, what I have
> > figured out that works:
> > Dim xSvc As some.server.WebService
> > Dim gString As String = xSvc.mystruct().result
> >
> > So, the question is how do I return the structure into an object (using
> > only
> > one call) which will allow me to access each of the structures values.
> > Something like this for example:
> >
> > Dim xSvc As some.server.WebService
> > Dim gOB As Object = xSvc.mystruct()
> >
> > gString = gOB.Result
> > dError = gOB.Error
> >
> >
> > I can't seem to find any info on this?
> >
> >

>
> It would need to be a known XML serialized object returned from the XML Web
> service in order for you to cast the object back to a known object type.
>
> You can't use Object because that is a generic object, and even a generic
> Object would have to be cast to a known type object for you to address any
> properties or methods of the known object type.
>
> The only way you can use it without it being a known object on the client
> side would also include that the Web service send it back as a known object
> on the Web service side, where as, you can use a "var" on the client side.
>
> I'll assume that "var" can be used in VB like it can be used in C#.
>
> var myobject = xSvc.someWebserviceMethod -- the Web service method returned
> a known serialized object on its side to the client.
>
> Then you can do gString = myobject.Result and gError = myobject.Error, if
> those are the two properties being sent back for the object sent by the XML
> Web service.
>
> If an object is not being sent back by the Web service, then it's going to
> the XML that is sent back where it would be a known xsd for the XML that
> you would use to address on the client side for Result and Error tags.
>
> That's how things work, and you can't make it up on the client side. The
> client side has to know what is coming back from the Web service side, and
> then you can do with it what ever you want to after you get it and address
> it.
>


Ok, I understand, so how can I found out what kind of object is being
returned via the WSDL?

 
Reply With Quote
 
Andrew
Guest
Posts: n/a
 
      14th Apr 2009

"Mr. Arnold" wrote:

> "Andrew" <(E-Mail Removed)> wrote in message
> news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
> >I am trying to access a web service method (that was written in C#) which
> > returns a structure. I am programming my side in VB.Net.
> >
> > So the c# struct looks like:
> > public struct mystruc {
> > public string result;
> > public int error;
> > }
> >
> > This is what I have in my code, or more to the point, what I have
> > figured out that works:
> > Dim xSvc As some.server.WebService
> > Dim gString As String = xSvc.mystruct().result
> >
> > So, the question is how do I return the structure into an object (using
> > only
> > one call) which will allow me to access each of the structures values.
> > Something like this for example:
> >
> > Dim xSvc As some.server.WebService
> > Dim gOB As Object = xSvc.mystruct()
> >
> > gString = gOB.Result
> > dError = gOB.Error
> >
> >
> > I can't seem to find any info on this?
> >
> >

>
> It would need to be a known XML serialized object returned from the XML Web
> service in order for you to cast the object back to a known object type.
>
> You can't use Object because that is a generic object, and even a generic
> Object would have to be cast to a known type object for you to address any
> properties or methods of the known object type.
>
> The only way you can use it without it being a known object on the client
> side would also include that the Web service send it back as a known object
> on the Web service side, where as, you can use a "var" on the client side.
>
> I'll assume that "var" can be used in VB like it can be used in C#.
>
> var myobject = xSvc.someWebserviceMethod -- the Web service method returned
> a known serialized object on its side to the client.
>
> Then you can do gString = myobject.Result and gError = myobject.Error, if
> those are the two properties being sent back for the object sent by the XML
> Web service.
>
> If an object is not being sent back by the Web service, then it's going to
> the XML that is sent back where it would be a known xsd for the XML that
> you would use to address on the client side for Result and Error tags.
>
> That's how things work, and you can't make it up on the client side. The
> client side has to know what is coming back from the Web service side, and
> then you can do with it what ever you want to after you get it and address
> it.
>



Sorry for the second post, but here's something that might help you
understand.

Given the structure that is returned as above. If I declare my variable as
something invalid, the Tool Tip Shows 'Value of Type WebService.mystruct
cannot be converted to ...'


 
Reply With Quote
 
Family Tree Mike
Guest
Posts: n/a
 
      14th Apr 2009
"Andrew" <(E-Mail Removed)> wrote in message
news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
>I am trying to access a web service method (that was written in C#) which
> returns a structure. I am programming my side in VB.Net.
>
> So the c# struct looks like:
> public struct mystruc {
> public string result;
> public int error;
> }
>
> This is what I have in my code, or more to the point, what I have
> figured out that works:
> Dim xSvc As some.server.WebService
> Dim gString As String = xSvc.mystruct().result
>
> So, the question is how do I return the structure into an object (using
> only
> one call) which will allow me to access each of the structures values.
> Something like this for example:
>
> Dim xSvc As some.server.WebService
> Dim gOB As Object = xSvc.mystruct()
>
> gString = gOB.Result
> dError = gOB.Error
>
>
> I can't seem to find any info on this?
>
>



Is xSvc.mystruct() a function returning a WebService.mystruct object?

I believe that your code above would be:

dim xSvc as some.server.WebService
dim gOB as some.server.WebService.mystruct

gString = gOB.Result
dError = gOB.Error


--
Mike

 
Reply With Quote
 
Andrew
Guest
Posts: n/a
 
      14th Apr 2009


"Family Tree Mike" wrote:

> "Andrew" <(E-Mail Removed)> wrote in message
> news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
> >I am trying to access a web service method (that was written in C#) which
> > returns a structure. I am programming my side in VB.Net.
> >
> > So the c# struct looks like:
> > public struct mystruc {
> > public string result;
> > public int error;
> > }
> >
> > This is what I have in my code, or more to the point, what I have
> > figured out that works:
> > Dim xSvc As some.server.WebService
> > Dim gString As String = xSvc.mystruct().result
> >
> > So, the question is how do I return the structure into an object (using
> > only
> > one call) which will allow me to access each of the structures values.
> > Something like this for example:
> >
> > Dim xSvc As some.server.WebService
> > Dim gOB As Object = xSvc.mystruct()
> >
> > gString = gOB.Result
> > dError = gOB.Error
> >
> >
> > I can't seem to find any info on this?
> >
> >

>
>
> Is xSvc.mystruct() a function returning a WebService.mystruct object?
>
> I believe that your code above would be:
>
> dim xSvc as some.server.WebService
> dim gOB as some.server.WebService.mystruct
>
> gString = gOB.Result
> dError = gOB.Error
>
>
> --
> Mike
>



Cool! Actually it was:

dim xSvc as some.server.WebService
dim gOB as some.server.mystruct

Thanks Mike! Most appreciated.

 
Reply With Quote
 
Mr. Arnold
Guest
Posts: n/a
 
      14th Apr 2009

"Andrew" <(E-Mail Removed)> wrote in message
news:A7E052DA-2A38-4032-9718-(E-Mail Removed)...
>
>
> "Family Tree Mike" wrote:
>
>> "Andrew" <(E-Mail Removed)> wrote in message
>> news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
>> >I am trying to access a web service method (that was written in C#)
>> >which
>> > returns a structure. I am programming my side in VB.Net.
>> >
>> > So the c# struct looks like:
>> > public struct mystruc {
>> > public string result;
>> > public int error;
>> > }
>> >
>> > This is what I have in my code, or more to the point, what I have
>> > figured out that works:
>> > Dim xSvc As some.server.WebService
>> > Dim gString As String = xSvc.mystruct().result
>> >
>> > So, the question is how do I return the structure into an object (using
>> > only
>> > one call) which will allow me to access each of the structures values.
>> > Something like this for example:
>> >
>> > Dim xSvc As some.server.WebService
>> > Dim gOB As Object = xSvc.mystruct()
>> >
>> > gString = gOB.Result
>> > dError = gOB.Error
>> >
>> >
>> > I can't seem to find any info on this?
>> >
>> >

>>
>>
>> Is xSvc.mystruct() a function returning a WebService.mystruct object?
>>
>> I believe that your code above would be:
>>
>> dim xSvc as some.server.WebService
>> dim gOB as some.server.WebService.mystruct
>>
>> gString = gOB.Result
>> dError = gOB.Error
>>
>>
>> --
>> Mike
>>

>
>
> Cool! Actually it was:
>
> dim xSvc as some.server.WebService
> dim gOB as some.server.mystruct
>
> Thanks Mike! Most appreciated.
>


I don't know if this is in VB.net, as I have not had the opportunity to use
VB.Net for a while now. But with "var", you can just do this.

var gOB = WebService.mystruct;

http://wiki.asp.net/page.aspx/421/ne...rquot-keyword/

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      14th Apr 2009
Mr. Arnold,

The C# "Var" is simple the same as the VB "Dim" as used with option Infer On
in VB. They both are then strongly typed

The Visual Basic Var is a variable, behaves like a kind of non strongly
typed object but then on the stack (Does not exist in to be build VB
versions later then version 6).

Cor


"Mr. Arnold" <MR. (E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Andrew" <(E-Mail Removed)> wrote in message
> news:A7E052DA-2A38-4032-9718-(E-Mail Removed)...
>>
>>
>> "Family Tree Mike" wrote:
>>
>>> "Andrew" <(E-Mail Removed)> wrote in message
>>> news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
>>> >I am trying to access a web service method (that was written in C#)
>>> >which
>>> > returns a structure. I am programming my side in VB.Net.
>>> >
>>> > So the c# struct looks like:
>>> > public struct mystruc {
>>> > public string result;
>>> > public int error;
>>> > }
>>> >
>>> > This is what I have in my code, or more to the point, what I have
>>> > figured out that works:
>>> > Dim xSvc As some.server.WebService
>>> > Dim gString As String = xSvc.mystruct().result
>>> >
>>> > So, the question is how do I return the structure into an object
>>> > (using
>>> > only
>>> > one call) which will allow me to access each of the structures values.
>>> > Something like this for example:
>>> >
>>> > Dim xSvc As some.server.WebService
>>> > Dim gOB As Object = xSvc.mystruct()
>>> >
>>> > gString = gOB.Result
>>> > dError = gOB.Error
>>> >
>>> >
>>> > I can't seem to find any info on this?
>>> >
>>> >
>>>
>>>
>>> Is xSvc.mystruct() a function returning a WebService.mystruct object?
>>>
>>> I believe that your code above would be:
>>>
>>> dim xSvc as some.server.WebService
>>> dim gOB as some.server.WebService.mystruct
>>>
>>> gString = gOB.Result
>>> dError = gOB.Error
>>>
>>>
>>> --
>>> Mike
>>>

>>
>>
>> Cool! Actually it was:
>>
>> dim xSvc as some.server.WebService
>> dim gOB as some.server.mystruct
>>
>> Thanks Mike! Most appreciated.
>>

>
> I don't know if this is in VB.net, as I have not had the opportunity to
> use VB.Net for a while now. But with "var", you can just do this.
>
> var gOB = WebService.mystruct;
>
> http://wiki.asp.net/page.aspx/421/ne...rquot-keyword/


 
Reply With Quote
 
Michel Posseth [MCP]
Guest
Posts: n/a
 
      14th Apr 2009
> The Visual Basic Var is a variable, behaves like a kind of non strongly
> typed object but then on the stack (Does not exist in to be build VB
> versions later then version 6).


i guess you mean the vb legacy variant datatype with that ?



"Cor Ligthert[MVP]" <(E-Mail Removed)> schreef in bericht
news:OT%(E-Mail Removed)...
> Mr. Arnold,
>
> The C# "Var" is simple the same as the VB "Dim" as used with option Infer
> On in VB. They both are then strongly typed
>
> The Visual Basic Var is a variable, behaves like a kind of non strongly
> typed object but then on the stack (Does not exist in to be build VB
> versions later then version 6).
>
> Cor
>
>
> "Mr. Arnold" <MR. (E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>
>> "Andrew" <(E-Mail Removed)> wrote in message
>> news:A7E052DA-2A38-4032-9718-(E-Mail Removed)...
>>>
>>>
>>> "Family Tree Mike" wrote:
>>>
>>>> "Andrew" <(E-Mail Removed)> wrote in message
>>>> news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
>>>> >I am trying to access a web service method (that was written in C#)
>>>> >which
>>>> > returns a structure. I am programming my side in VB.Net.
>>>> >
>>>> > So the c# struct looks like:
>>>> > public struct mystruc {
>>>> > public string result;
>>>> > public int error;
>>>> > }
>>>> >
>>>> > This is what I have in my code, or more to the point, what I have
>>>> > figured out that works:
>>>> > Dim xSvc As some.server.WebService
>>>> > Dim gString As String = xSvc.mystruct().result
>>>> >
>>>> > So, the question is how do I return the structure into an object
>>>> > (using
>>>> > only
>>>> > one call) which will allow me to access each of the structures
>>>> > values.
>>>> > Something like this for example:
>>>> >
>>>> > Dim xSvc As some.server.WebService
>>>> > Dim gOB As Object = xSvc.mystruct()
>>>> >
>>>> > gString = gOB.Result
>>>> > dError = gOB.Error
>>>> >
>>>> >
>>>> > I can't seem to find any info on this?
>>>> >
>>>> >
>>>>
>>>>
>>>> Is xSvc.mystruct() a function returning a WebService.mystruct object?
>>>>
>>>> I believe that your code above would be:
>>>>
>>>> dim xSvc as some.server.WebService
>>>> dim gOB as some.server.WebService.mystruct
>>>>
>>>> gString = gOB.Result
>>>> dError = gOB.Error
>>>>
>>>>
>>>> --
>>>> Mike
>>>>
>>>
>>>
>>> Cool! Actually it was:
>>>
>>> dim xSvc as some.server.WebService
>>> dim gOB as some.server.mystruct
>>>
>>> Thanks Mike! Most appreciated.
>>>

>>
>> I don't know if this is in VB.net, as I have not had the opportunity to
>> use VB.Net for a while now. But with "var", you can just do this.
>>
>> var gOB = WebService.mystruct;
>>
>> http://wiki.asp.net/page.aspx/421/ne...rquot-keyword/

>


 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      15th Apr 2009
I thought it does not exist anymore after version 6 but that the variant
exist in VBS and VBA, so it is not legacy

Cor

"Michel Posseth [MCP]" <(E-Mail Removed)> wrote in message
news:41DF5B11-0657-4945-AEE5-(E-Mail Removed)...
>> The Visual Basic Var is a variable, behaves like a kind of non strongly
>> typed object but then on the stack (Does not exist in to be build VB
>> versions later then version 6).

>
> i guess you mean the vb legacy variant datatype with that ?
>
>
>
> "Cor Ligthert[MVP]" <(E-Mail Removed)> schreef in bericht
> news:OT%(E-Mail Removed)...
>> Mr. Arnold,
>>
>> The C# "Var" is simple the same as the VB "Dim" as used with option Infer
>> On in VB. They both are then strongly typed
>>
>> The Visual Basic Var is a variable, behaves like a kind of non strongly
>> typed object but then on the stack (Does not exist in to be build VB
>> versions later then version 6).
>>
>> Cor
>>
>>
>> "Mr. Arnold" <MR. (E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>
>>> "Andrew" <(E-Mail Removed)> wrote in message
>>> news:A7E052DA-2A38-4032-9718-(E-Mail Removed)...
>>>>
>>>>
>>>> "Family Tree Mike" wrote:
>>>>
>>>>> "Andrew" <(E-Mail Removed)> wrote in message
>>>>> news:730C3BD7-1FA5-4688-A0A1-(E-Mail Removed)...
>>>>> >I am trying to access a web service method (that was written in C#)
>>>>> >which
>>>>> > returns a structure. I am programming my side in VB.Net.
>>>>> >
>>>>> > So the c# struct looks like:
>>>>> > public struct mystruc {
>>>>> > public string result;
>>>>> > public int error;
>>>>> > }
>>>>> >
>>>>> > This is what I have in my code, or more to the point, what I have
>>>>> > figured out that works:
>>>>> > Dim xSvc As some.server.WebService
>>>>> > Dim gString As String = xSvc.mystruct().result
>>>>> >
>>>>> > So, the question is how do I return the structure into an object
>>>>> > (using
>>>>> > only
>>>>> > one call) which will allow me to access each of the structures
>>>>> > values.
>>>>> > Something like this for example:
>>>>> >
>>>>> > Dim xSvc As some.server.WebService
>>>>> > Dim gOB As Object = xSvc.mystruct()
>>>>> >
>>>>> > gString = gOB.Result
>>>>> > dError = gOB.Error
>>>>> >
>>>>> >
>>>>> > I can't seem to find any info on this?
>>>>> >
>>>>> >
>>>>>
>>>>>
>>>>> Is xSvc.mystruct() a function returning a WebService.mystruct object?
>>>>>
>>>>> I believe that your code above would be:
>>>>>
>>>>> dim xSvc as some.server.WebService
>>>>> dim gOB as some.server.WebService.mystruct
>>>>>
>>>>> gString = gOB.Result
>>>>> dError = gOB.Error
>>>>>
>>>>>
>>>>> --
>>>>> Mike
>>>>>
>>>>
>>>>
>>>> Cool! Actually it was:
>>>>
>>>> dim xSvc as some.server.WebService
>>>> dim gOB as some.server.mystruct
>>>>
>>>> Thanks Mike! Most appreciated.
>>>>
>>>
>>> I don't know if this is in VB.net, as I have not had the opportunity to
>>> use VB.Net for a while now. But with "var", you can just do this.
>>>
>>> var gOB = WebService.mystruct;
>>>
>>> http://wiki.asp.net/page.aspx/421/ne...rquot-keyword/

>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call this native function with a struct in a struct ? Peter Microsoft Dot NET Compact Framework 1 22nd Mar 2007 10:06 PM
Converting a C struct to C# for a P/Invoke call (struct in structs and unions) Tom Hellström Microsoft Dot NET Framework 4 14th Jul 2005 01:10 PM
Marshaling a string (and struct) for call to SendMessage Adam Clauss Microsoft C# .NET 5 3rd Aug 2004 04:10 PM
Re: api call using struct* Mattias Sjögren Microsoft VB .NET 0 7th Jul 2004 03:45 PM
c++ function call with struct... BMermuys Microsoft C# .NET 3 30th Mar 2004 07:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:11 PM.