Solved

Create ASP.NET VB Web Service with Array

Posted on 2011-02-16
1
3,158 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 500 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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Form Data Disappears Using Back Button 4 66
SQL to JSON 14 65
Need to find a web event on the IIS server 4 52
WordPress:  Reset File Permission after server migration 5 61
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

734 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