?
Solved

Create ASP.NET VB Web Service with Array

Posted on 2011-02-16
1
Medium Priority
?
3,276 Views
Last Modified: 2013-11-18
Hi all, I'm new at the web service development thing...and hopefully someone can help me design a basic web service that does the following:

Receives three pieces of data:

- OrderID (Int32)
- OrderStatus (String, 1)
- OrderDate (DateTime)

Now, if the client was connecting to the web service and giving me one record at a time with a response, it would be a no-brainer on how to create this...

Basically, what I need to do is accept multiple records at once...Is an array the best way to accept?

Then, if all succeeds, I send them back a message or code that says the import was successful.  If it failed, (or a record or two failed), I send them back an array or something that tells them which orders failed to be accepted.

Any code examples in VB would be greatly appreciated.
0
Comment
Question by:ripple123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
mohanupadhyay earned 2000 total points
ID: 34913766
File => New Project => VB Web Service Application

add following function into service1.asmx file

<WebMethod()> _
    Public Function ImportOrders(ByVal orderid As Integer()) As Integer()
        Dim failed As Integer()
        Dim i As Integer, k As Integer

        k = 0
        For i = 0 To orderid.Length - 1
            If orderid(i) < 1 Or orderid(i) > 10 Then
                ReDim failed(k + 1)
                failed(k) = orderid(i)
            End If
        Next
        Return failed
    End Function

'===========================================================================

Add a web form and add the following code on page load event

Dim obj As New Service1
        Dim orderids As Integer() = {2, 11, 1, 10}
        Dim failed As Integer()
        failed = obj.ImportOrders(orderids)

        Dim i As Integer
        For i = 0 To failed.Length - 1
            Response.Write(failed(i).ToString() + "<br>")
        Next

'===================================================================


0

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question