473,545 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

web service - returning array of custom type

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

[html]<xs:complexTy pe name="employeeT ype">
<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:complexTy pe name="employeeL istType">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbo unded" name="employee" type="usxs:empl oyeeType" />
</xs:sequence>
</xs:complexType>[/html]


Then the wsdl defines the request and response types as:

[html]- <xs:complexTy pe name="getAllEmp loyeesRequestTy pe">
- <xs:complexCont ent mixed="false">
<xs:extension base="usxs:quer yRequestType" />
</xs:complexConte nt>
</xs:complexType>
- <xs:complexTy pe name="getAllEmp loyeesResponseT ype">
- <xs:complexCont ent mixed="false">

- <xs:extension base="usxs:quer yResponseType">
- <xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbo unded" name="employees " type="usxs:empl oyeeListType" />
</xs:sequence>
</xs:extension>
</xs:complexConte nt>
</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 "getAllEmployee s"
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]- <ArrayOfEmploye e xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http ://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
- <employee>
<FirstName>Robi n</FirstName>
<LastNameName>S harma</LastName>
</employee>
- <employee>
<FirstName>Paul o</FirstName>
<LastNameName>C oelho</LastName>
</employee>
</ArrayOfEmployee >[/html]

I dont want the "ArrayOfEmploye e" tag!! I need the employees to be within a <EmployeeList > tag!! How do I do this?
Apr 26 '07 #1
3 2870
dorinbogdan
839 Recognized Expert Contributor
Welcome to TheScripts...

<ArrayOfEmploye e> 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 New Member
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>Robi n</FirstName>
<LastNameName>S harma</LastName>
</employee>
- <employee>
<FirstName>Paul o</FirstName>
<LastNameName>C oelho</LastName>
</employee>
</EmployeeList>[/html]

How do I achieve this?
Apr 26 '07 #3
dorinbogdan
839 Recognized Expert Contributor
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
2321
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 to application server, I did not get the result in the C# client side, I used a soap monitor to look at the SOAP messages that were exchanged, I can...
2
29781
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
2315
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 having to do a httpwebreqeust call.
1
4161
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 Service returns me an object which is a wrapper around an array of objects. (Earlier I was trying to read the array directly but could not succeed - so I...
3
5650
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 the web method from a client host I am getting back a 1-dimensional array and I can't convert each item in the array to the appropriate custom type...
3
4979
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 : >************************************************************************ > <WebMethod(), System.Web.Services.Protocols.SoapRpcMethod()> _ > Public Function...
1
1681
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 = consumeWebService.GetPublishedDatabases("1.0", Results).ToString The problem is that the array "Results" is always 'Nothing' - that is it never gets filled with...
15
13486
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 http://msdn2.microsoft.com/en-us/library/ms996381.aspx Formerly, with classic Microsoft DNA architecture, the ADO Recordset was a primary transport medium, recommended for transmitting data...
2
2622
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 both .Net shops and this would seem to be the easiest method. But I ran into one snafu. I wanted to return to the subsidiary an ArrayList of my...
0
7486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7416
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7676
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7932
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5347
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.