Best way to send data to webmethod

P

PA

Hi,

I have to write a webmethod to process some data which accepts few
parameters of type string, integer and then I have to pass collection
of data to get result back from webmethod.

collection of data may look like this:
<item>
<id>1</id>
<qty>11</qty>
</item>
<item>
<id>2</id>
<qty>22</qty>
</item>

My question is:

Should I use XMLNode type parameter to accept this data or should I
create a class of type Item and accept class type object?

Currently, I have done it both ways. Both are working fine. Both have
their own + and - points as far as my knowledge is concerned.

with XMLNode type:
+ point: I can validate data easily using XMLValidatingReader
- point: soap message looks like
<soap:Item>xml</soap:Item>
which gives no clue of its elements.

With Class type object:
+ point: Proper structure appears in soap message
<soap:Item>
<soap:ID>string</soap:ID>
<soap:Qty>int</soap:Qty>
</soap:Item>

- point: I am not able to validate incoming soap message.
I have reached to the stage where I can log incoming soap message
through Soap extension but don't know how to validate it. If I create
a class of type item in client side with extra parameter say Desc and
pass that class or even if I remove parameter say Qty from client
class and send that class as a parameter webemethod does not throw any
error.

Can anyone guide me what is the best way of sending data of Item type
to webmethod? and how to achieve that? also, can anyone provide me
code to validate incoming soap message?

Thanks in advance.

Pratibha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top