Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

How to return an ArrayList from a web service

I created a class employee and a web service method

Puclic Class Employee
Private _EmpID as String
Private _Name as String
   :
End Class

<WebMethod()> Function GetEmpList() As ArrayList
Dim list as New ArrayList
list.add(new Employee("Alice", "123456"))
   :
End Function

But it seems that no employee data return from the method.
How can i get a list of employees from web services?

Can anyone post some sample code or tell me where i can find solutions.
0
tyknight
Asked:
tyknight
1 Solution
 
Michel SakrCommented:
hmm
Can you post how you are calling it from the client?
also try this proxy trace tool to debug your calls
http://www.pocketsoap.com/tcptrace/pt.asp

0
 
tyknightAuthor Commented:

 Dim kbs As New KBSEmp.Agent()
 Dim list As New ArrayList()
 list = kbs.GetEmpList()

SOAP response:

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetEmpListResponse xmlns="http://kbs.localhost.org/">
<GetEmpListResult>
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
</GetEmpListResult>
</GetEmpListResponse>
</soap:Body>
</soap:Envelope>
0
 
tyknightAuthor Commented:

 Dim kbs As New KBSEmp.Agent()
 Dim list As New ArrayList()
 list = kbs.GetEmpList()

SOAP response:

<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetEmpListResponse xmlns="http://kbs.localhost.org/">
<GetEmpListResult>
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
<anyType xsi:type="Employee" />
</GetEmpListResult>
</GetEmpListResponse>
</soap:Body>
</soap:Envelope>
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
Joe_GriffithCommented:
I think you need to tell the function what to return:

<WebMethod()> Function GetEmpList() As ArrayList
Dim list as New ArrayList
  list.add(new Employee("Alice", "123456"))
  :
  Return list   ' <--<<<
End Function
0
 
tyknightAuthor Commented:
The line "Return list" is in the web service method already.
0
 
tyknightAuthor Commented:
The line "Return list" is in the web service method already.
0
 
tyknightAuthor Commented:
I have fixed the problem. I use public instead of private

Puclic Class Employee
Public _EmpID as String  <-- use Public
Public _Name as String   <-- use Public
  :
End Class
0
 
Bob LearnedCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/Refund

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now