Returned Value From Web Service

  • Thread starter Teeravee Sirinapasawasdee
  • Start date
T

Teeravee Sirinapasawasdee

Here is some code from my web service

<WebMethod()> Public Function GetProduct() As Products
Dim a As Product
Dim p As New Products()
Return CType(p, Products)
End Function

What I get is something like below:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfProduct xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.gestaltsolutions.net/">
<Product>
<Name>1</Name>
<ProductID>1</ProductID>
</Product>
<Product>
<Name>2</Name>
<ProductID>2</ProductID>
</Product>
<Product>
<Name>3</Name>
<ProductID>3</ProductID>
</Product>
<Product>
<Name>4</Name>
<ProductID>4</ProductID>
</Product>
<Product>
<Name>5</Name>
<ProductID>5</ProductID>
</Product>
<Product>
<Name>6</Name>
<ProductID>6</ProductID>
</Product>
<Product>
<Name>7</Name>
<ProductID>7</ProductID>
</Product>
<Product>
<Name>8</Name>
<ProductID>8</ProductID>
</Product>
<Product>
<Name>9</Name>
<ProductID>9</ProductID>
</Product>
<Product>
<Name>10</Name>
<ProductID>10</ProductID>
</Product>
<Product>
<Name>11</Name>
<ProductID>11</ProductID>
</Product>
<Product>
<Name>12</Name>
<ProductID>12</ProductID>
</Product>
<Product>
<Name>13</Name>
<ProductID>13</ProductID>
</Product>
<Product>
<Name>14</Name>
<ProductID>14</ProductID>
</Product>
<Product>
<Name>15</Name>
<ProductID>15</ProductID>
</Product>
<Product>
<Name>16</Name>
<ProductID>16</ProductID>
</Product>
<Product>
<Name>17</Name>
<ProductID>17</ProductID>
</Product>
<Product>
<Name>18</Name>
<ProductID>18</ProductID>
</Product>
<Product>
<Name>19</Name>
<ProductID>19</ProductID>
</Product>
<Product>
<Name>20</Name>
<ProductID>20</ProductID>
</Product>
</ArrayOfProduct>

My problem is if I want to change return datatype from "ArrayOfProduct" to
"Products", is it possible to do that? If yes how do I do to change it?
 
S

ShikariShambu

I don't think there is a way to do this automatically. You will have to
write a wrapper that takes this array and returns a collection.

HTH
 

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

Top