473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

web service - returning array of custom type

5
Hi,
I have the following type definition in my wsdl.

[html]<xs:complexType name="employeeType">
<xs:all>
<xs:element name="FirstName" type="xs:string" />
<xs:element name="LastName" type="xs:string" />
</xs:all>
</xs:complexType>[/html]

Then I have this definition for a list(array) of employees:

[html]<xs:complexType name="employeeListType">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="employee" type="usxs:employeeType" />
</xs:sequence>
</xs:complexType>[/html]


Then the wsdl defines the request and response types as:

[html]- <xs:complexType name="getAllEmployeesRequestType">
- <xs:complexContent mixed="false">
<xs:extension base="usxs:queryRequestType" />
</xs:complexContent>
</xs:complexType>
- <xs:complexType name="getAllEmployeesResponseType">
- <xs:complexContent mixed="false">

- <xs:extension base="usxs:queryResponseType">
- <xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="employees" type="usxs:employeeListType" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>[/html]

Given these details...how do I write my web method? I tried the following:
1. I created a class called "employee"
2. I created a web method "getAllEmployees"
In this method, I am creating an array of type employee and after populating values am returning this array.
But the output is something like this:
[html]- <ArrayOfEmployee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
- <employee>
<FirstName>Robin</FirstName>
<LastNameName>Sharma</LastName>
</employee>
- <employee>
<FirstName>Paulo</FirstName>
<LastNameName>Coelho</LastName>
</employee>
</ArrayOfEmployee>[/html]

I dont want the "ArrayOfEmployee" tag!! I need the employees to be within a <EmployeeList> tag!! How do I do this?
Apr 26 '07 #1
3 2866
dorinbogdan
839 Expert 512MB
Welcome to TheScripts...

<ArrayOfEmployee> tag is generated automatically?
If cannot be changed then you might have to rename it (manually or by code) after the output is issued.

Dorin.
Apr 26 '07 #2
Sinex
5
yes, the ArrayOfEmployee is generated automatically. Whereas I want my output to be:

[html]- <EmployeeList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
- <employee>
<FirstName>Robin</FirstName>
<LastNameName>Sharma</LastName>
</employee>
- <employee>
<FirstName>Paulo</FirstName>
<LastNameName>Coelho</LastName>
</employee>
</EmployeeList>[/html]

How do I achieve this?
Apr 26 '07 #3
dorinbogdan
839 Expert 512MB
Possible solutions:
1. Load the xml into a String variable and call Replace() method as desired.
2. Load the xml into a XMLDocument object and rename the root element as desired, see this link.
3. Create an XSL and apply on your XML, see this link.
Apr 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: psy000 | last post by:
Hi, I have a C# web service client that talks to a JAVA application sever. I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy stub c# code. When I try to use c# client connect...
2
by: Douglas Robson | last post by:
Hi, I've got a simple C# web service. That has the following method. public MyItem getMyItem() { MyItem i = new MyItem(); return i; }
6
by: kbs | last post by:
Hi, I'm looking for some good examples that illustrate how to code a web service that exposes a custom collection so that the properties of the collection are accessible on the client without...
1
by: Vaibhav Modak | last post by:
Hi All, I have a Web Service written in Java (Web Logic) and I am trying to call it in my ASP. NET client. I am facing a problem while getting the data from the Web Service Method. My Web...
3
by: Malcolm | last post by:
Hi. I am attempting something new in my coding and need some direction. I have a web service that I am attempting to return a custom colleciton of custom objects of a single type. When I call...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
1
by: Matthew | last post by:
Using .NET 1.1 I trying to consume a web service that returns an integer and an array of type string which I declare and use line this Dim Results() As String Me.txtMain.Text =...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
2
by: =?Utf-8?B?RHJldw==?= | last post by:
I have a current requirement to all a subsidiary to use a current legacy application and interface with my new system to inject data when appropriate. I wanted to create a web service since we are...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.