473,748 Members | 10,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read WebService List<> data

I have a WebService which returns a List of RunningReport class
How do I read this XML data on the client side. How do I convert
List<RunningRep ortfrom the WebService side to List<RunningRep orton the
client side

I have tried the following:

List<RunningRep ortreportList = null;

localhost.Repor tService localrs = new localhost.Repor tService();
localrs.Url = GetServiceURL() ;
reportList = localrs.Running Reports();
but I am getting the following error

Error 67 Cannot implicitly convert type 'localhost.Runn ingReport[]' to
'System.Collect ions.Generic.Li st<Reports.Modu les.RunningJobs .RunningReport>
Thank You

Peter
//////////////// Heres' the XML data from the WebService
///////////////////////////////////

<?xml version="1.0" encoding="utf-8" ?>
ArrayOfRunningR eport xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns="http://wsinc.com/webservices/">
<RunningRepor t>
<ReportID>0</ReportID>
<CreatedBy>12 </CreatedBy>
<ItemId>1</ItemId>
<OutputType>PDF </OutputType>
</RunningReport>
<RunningRepor t>
<ReportID>0</ReportID>
<CreatedBy>12 </CreatedBy>
<ItemId>2</ItemId>
<OutputType>PDF </OutputType>
</RunningReport>
</ArrayOfRunningR eport>
///////////////////////////////////// Here's the class that the Webservice
is returning: ////////////////////////////////////////////

using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;

namespace ReportInfoLib
{
[Serializable]
public class RunningReport
{
private string _reportName;
private int _reportID;
private int _createdBy;
private string _discription;
private int _itemId;
private DocumentTypeEnu m _outputType;
private string _printerName;
private string _trayName;
private string _emailList;
private List<ParameterN ameValue_pnv;

public string ReportName
{
get { return this._reportNam e; }
set { this._reportNam e = value; }
}

public int ReportID
{
get { return this._reportID; }
set { this._reportID = value; }
}

public int CreatedBy
{
get { return this._createdBy ; }
set { this._createdBy = value; }
}

public string Discription
{
get { return this._discripti on; }
set { this._discripti on = value; }
}

public int ItemId
{
get { return this._itemId; }
set { this._itemId = value; }
}

public ReportInfoLib.D ocumentTypeEnum OutputType
{
get { return this._outputTyp e; }
set { this._outputTyp e = value; }
}

public string PrinterName
{
get { return this._printerNa me; }
set { this._printerNa me = value; }
}

public string TrayName
{
get { return this._trayName; }
set { this._trayName = value; }
}

public string EmailList
{
get { return this._emailList ; }
set { this._emailList = value; }
}

public
System.Collecti ons.Generic.Lis t<ReportInfoLib .ParameterNameV aluePnv
{
get { return this._pnv; }
set { this._pnv = value; }
}
}
}
Oct 9 '08 #1
6 2984
"Peter" <cz****@nospam. nospamwrote in message
news:uq******** ******@TK2MSFTN GP02.phx.gbl...
I have a WebService which returns a List of RunningReport class
How do I read this XML data on the client side. How do I convert
List<RunningRep ortfrom the WebService side to List<RunningRep orton the
client side
Sorry, it doesn't work this way.

The client has no idea what type the server is using. Remember that the
client could be running Java, in which case, it certainly doesn't know
anything about List<RunningRep ort>.

What the client _does_ know about is the XML Schema that it gets from the
WSDL file that it gets from the server when you use Add Web Reference. That
schema will have a section similar to this:

<xs:element name="ArrayOfRu nningReport">
<xs:complexType >
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbo unded" type="RunningRe port"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Notice the total lack of mention of List<T>.

Using ASMX web services (which you seem to be doing), that will always
translate into RunningReport[] on the client. If you were using WCF, you'd
be able to tell it to use List<Tinstead. Since you're using the old stuff,
you'll have to fake it:

List<RunningRep ortreportList ; //= null; Don't do this. The
default is null, besides, it gets overwritten

localhost.Repor tService localrs = new localhost.Repor tService();
localrs.Url = GetServiceURL() ;
RunningReports[] reportsArray = localrs.Running Reports();
reportList = new List<RunningRep orts>(reportsAr ray);

--
John Saunders | MVP - Connected System Developer
Oct 9 '08 #2

"John Saunders" <no@dont.do.tha t.comwrote in message
news:Oc******** ******@TK2MSFTN GP05.phx.gbl...
"Peter" <cz****@nospam. nospamwrote in message
news:uq******** ******@TK2MSFTN GP02.phx.gbl...
>I have a WebService which returns a List of RunningReport class
How do I read this XML data on the client side. How do I convert
List<RunningRe portfrom the WebService side to List<RunningRep orton
the client side

Sorry, it doesn't work this way.

The client has no idea what type the server is using. Remember that the
client could be running Java, in which case, it certainly doesn't know
anything about List<RunningRep ort>.

What the client _does_ know about is the XML Schema that it gets from the
WSDL file that it gets from the server when you use Add Web Reference.
That schema will have a section similar to this:

<xs:element name="ArrayOfRu nningReport">
<xs:complexType >
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbo unded" type="RunningRe port"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Notice the total lack of mention of List<T>.

Using ASMX web services (which you seem to be doing), that will always
translate into RunningReport[] on the client. If you were using WCF, you'd
be able to tell it to use List<Tinstead. Since you're using the old
stuff, you'll have to fake it:

List<RunningRep ortreportList ; //= null; Don't do this. The
default is null, besides, it gets overwritten

localhost.Repor tService localrs = new localhost.Repor tService();
localrs.Url = GetServiceURL() ;
RunningReports[] reportsArray = localrs.Running Reports();
reportList = new List<RunningRep orts>(reportsAr ray);

--
John Saunders | MVP - Connected System Developer

Thank You for your help!

This the following line does not work:
RunningReports[] reportsArray = localrs.Running Reports();

Cannot implicitly convert type 'localhost.Runn ingReport[]' to
'Reports.Module s.RunningJobs.R unningReport[]'
Oct 10 '08 #3
Hi Peter,

The problem you encountered, is caused by XML webservice does not expose
implement details to client(only expose WSDL service description) for
interop purpose. Therefore, for any custom types used in webservice, by
default the client-side will generate a light weight delegate class to
represent it. That's why, for your scenario, it reports the following error:

=============== =
Cannot implicitly convert type 'localhost.Runn ingReport[]' to
'Reports.Module s.RunningJobs.R unningReport[]'
===============

here the "localhost.Runn ingReport" type is generated by the webservice
client proxy(add webreference), while
"Reports.Module s.RunningJobs.R unningReport" is your own type(the type used
at server-side).

Currently one way to overcome this problem is manually modify the
auto-generated webservice proxy's source code. You can change the return
type from the "localhost.Runn ingReport[]" to
"Reports.Module s.RunningJobs.R unningReport[]". The drawback of this is
when you update the webservice refefence, your change will be overwritten.
To avoid this, you can add a partial class file for the webservice clienet
proxy class, and add a new method (the same signature and attributes as the
original webmethod), and chang the return type to the one you want.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Peter" <cz****@nospam. nospam>
References: <uq************ **@TK2MSFTNGP02 .phx.gbl>
<Oc************ **@TK2MSFTNGP05 .phx.gbl>
>Subject: Re: Read WebService List<data
Date: Thu, 9 Oct 2008 21:19:42 -0500
>

"John Saunders" <no@dont.do.tha t.comwrote in message
news:Oc******* *******@TK2MSFT NGP05.phx.gbl.. .
>"Peter" <cz****@nospam. nospamwrote in message
news:uq******* *******@TK2MSFT NGP02.phx.gbl.. .
>>I have a WebService which returns a List of RunningReport class
How do I read this XML data on the client side. How do I convert
List<RunningR eportfrom the WebService side to List<RunningRep orton
the client side

Sorry, it doesn't work this way.

The client has no idea what type the server is using. Remember that the
client could be running Java, in which case, it certainly doesn't know
anything about List<RunningRep ort>.

What the client _does_ know about is the XML Schema that it gets from
the
>WSDL file that it gets from the server when you use Add Web Reference.
That schema will have a section similar to this:

<xs:element name="ArrayOfRu nningReport">
<xs:complexTyp e>
<xs:sequence >
<xs:element minOccurs="0" maxOccurs="unbo unded" type="RunningRe port"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Notice the total lack of mention of List<T>.

Using ASMX web services (which you seem to be doing), that will always
translate into RunningReport[] on the client. If you were using WCF,
you'd
>be able to tell it to use List<Tinstead. Since you're using the old
stuff, you'll have to fake it:

List<RunningRe portreportList ; //= null; Don't do this. The
default is null, besides, it gets overwritten

localhost.Repo rtService localrs = new localhost.Repor tService();
localrs.Url = GetServiceURL() ;
RunningRepor ts[] reportsArray = localrs.Running Reports();
reportList = new List<RunningRep orts>(reportsAr ray);

--
John Saunders | MVP - Connected System Developer


Thank You for your help!

This the following line does not work:
RunningRepor ts[] reportsArray = localrs.Running Reports();

Cannot implicitly convert type 'localhost.Runn ingReport[]' to
'Reports.Modul es.RunningJobs. RunningReport[]'
Oct 10 '08 #4
""Steven Cheng"" <st*****@online .microsoft.comw rote in message
news:hM******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Peter,

The problem you encountered, is caused by XML webservice does not expose
implement details to client(only expose WSDL service description) for
interop purpose. Therefore, for any custom types used in webservice, by
default the client-side will generate a light weight delegate class to
represent it. That's why, for your scenario, it reports the following
error:

=============== =
Cannot implicitly convert type 'localhost.Runn ingReport[]' to
'Reports.Module s.RunningJobs.R unningReport[]'
===============

here the "localhost.Runn ingReport" type is generated by the webservice
client proxy(add webreference), while
"Reports.Module s.RunningJobs.R unningReport" is your own type(the type used
at server-side).

Currently one way to overcome this problem is manually modify the
auto-generated webservice proxy's source code. You can change the return
type from the "localhost.Runn ingReport[]" to
"Reports.Module s.RunningJobs.R unningReport[]". The drawback of this is
when you update the webservice refefence, your change will be overwritten.
To avoid this, you can add a partial class file for the webservice clienet
proxy class, and add a new method (the same signature and attributes as
the
original webmethod), and chang the return type to the one you want.
As Steven has said, this will not work, as it will be overwritten every time
you update your web reference.

The correct solution is simply to use:

localhost.Runni ngReports[] reportsArray = localrs.Running Reports();
--
John Saunders | MVP - Connected System Developer
Oct 10 '08 #5

"John Saunders" <no@dont.do.tha t.comwrote in message
news:On******** ******@TK2MSFTN GP06.phx.gbl...
""Steven Cheng"" <st*****@online .microsoft.comw rote in message
news:hM******** ******@TK2MSFTN GHUB02.phx.gbl. ..
>Hi Peter,

The problem you encountered, is caused by XML webservice does not expose
implement details to client(only expose WSDL service description) for
interop purpose. Therefore, for any custom types used in webservice, by
default the client-side will generate a light weight delegate class to
represent it. That's why, for your scenario, it reports the following
error:

============== ==
Cannot implicitly convert type 'localhost.Runn ingReport[]' to
'Reports.Modul es.RunningJobs. RunningReport[]'
============== =

here the "localhost.Runn ingReport" type is generated by the webservice
client proxy(add webreference), while
"Reports.Modul es.RunningJobs. RunningReport" is your own type(the type
used
at server-side).

Currently one way to overcome this problem is manually modify the
auto-generated webservice proxy's source code. You can change the return
type from the "localhost.Runn ingReport[]" to
"Reports.Modul es.RunningJobs. RunningReport[]". The drawback of this is
when you update the webservice refefence, your change will be
overwritten.
To avoid this, you can add a partial class file for the webservice
clienet
proxy class, and add a new method (the same signature and attributes as
the
original webmethod), and chang the return type to the one you want.

As Steven has said, this will not work, as it will be overwritten every
time you update your web reference.

The correct solution is simply to use:

localhost.Runni ngReports[] reportsArray = localrs.Running Reports();
--
John Saunders | MVP - Connected System Developer

Thank You for your help, that worked!

I also switched to WCF, which works very nice.
Oct 10 '08 #6
Hi Peter,

I'm glad that you've got it working. If there is anything else need help
later, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.
--------------------
>From: "Peter" <cz****@nospam. nospam>
References: <uq************ **@TK2MSFTNGP02 .phx.gbl>
<Oc************ **@TK2MSFTNGP05 .phx.gbl>
<eD************ **@TK2MSFTNGP06 .phx.gbl>
<hM************ **@TK2MSFTNGHUB 02.phx.gbl>
<On************ **@TK2MSFTNGP06 .phx.gbl>
>Subject: Re: Read WebService List<data
Date: Fri, 10 Oct 2008 16:17:19 -0500
>
"John Saunders" <no@dont.do.tha t.comwrote in message
news:On******* *******@TK2MSFT NGP06.phx.gbl.. .
>""Steven Cheng"" <st*****@online .microsoft.comw rote in message
news:hM******* *******@TK2MSFT NGHUB02.phx.gbl ...
>>Hi Peter,

The problem you encountered, is caused by XML webservice does not expose
implement details to client(only expose WSDL service description) for
interop purpose. Therefore, for any custom types used in webservice, by
default the client-side will generate a light weight delegate class to
represent it. That's why, for your scenario, it reports the following
error:

============= ===
Cannot implicitly convert type 'localhost.Runn ingReport[]' to
'Reports.Modu les.RunningJobs .RunningReport[]'
============= ==

here the "localhost.Runn ingReport" type is generated by the webservice
client proxy(add webreference), while
"Reports.Modu les.RunningJobs .RunningReport" is your own type(the type
used
at server-side).

Currently one way to overcome this problem is manually modify the
auto-generated webservice proxy's source code. You can change the return
type from the "localhost.Runn ingReport[]" to
"Reports.Modu les.RunningJobs .RunningReport[]". The drawback of this is
when you update the webservice refefence, your change will be
overwritten .
To avoid this, you can add a partial class file for the webservice
clienet
proxy class, and add a new method (the same signature and attributes as
the
original webmethod), and chang the return type to the one you want.

As Steven has said, this will not work, as it will be overwritten every
time you update your web reference.

The correct solution is simply to use:

localhost.Runn ingReports[] reportsArray = localrs.Running Reports();
--
John Saunders | MVP - Connected System Developer


Thank You for your help, that worked!

I also switched to WCF, which works very nice.
Oct 13 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
5632
by: Dave | last post by:
Hello all, After perusing the Standard, I believe it is true to say that once you insert an element into a std::list<>, its location in memory never changes. This makes a std::list<> ideal for storing vertices of an arbitrary n-ary tree where a vertex contain pointers to its parent / children. These parent / child vertices need to stay put if we've got pointers to them somewhere! Am I correct in my assertion?
4
52997
by: matty.hall | last post by:
I have two classes: a base class (BaseClass) and a class deriving from it (DerivedClass). I have a List<DerivedClass> that for various reasons needs to be of that type, and not a List<BaseClass>. However, I need to cast that list to a List<BaseClass> and it is not working. The code is below. I get the following exception: "Unable to cast object of type 'System.Collections.Generic.List`1' to type 'System.Collections.Generic.List`1'." ...
0
1752
by: Iron Moped | last post by:
I'm airing frustration here, but why does LinkedList<not support the same sort and search methods as List<>? I want a container that does not support random access, allows forward and reverse traversal and natively supports sorting, i.e., STL's list<T>. There isn't even a set of algorithms that would allow me to easily sort a generic collection. System.Array has a robust set of static algorithms, why not extend this to ICollection?
7
57554
by: Andrew Robinson | last post by:
I have a method that needs to return either a Dictionary<k,vor a List<v> depending on input parameters and options to the method. 1. Is there any way to convert from a dictionary to a list without itterating through the entire collection and building up a list? 2. is there a common base class, collection or interface that can contain either/both of these collection types and then how do you convert or cast from the base to either a...
0
1351
by: SC | last post by:
How do I create at runtime a list of string (List<stringstrs = new List<string>(); fill it) and then bind it to a DataGridViewColumnBox? Setting the columns DataSource to the list doesn't display any data, i.e., OnNewRow Event: myDataViewGrid.Row.Cell.DataSource = strs;
35
5894
by: Lee Crabtree | last post by:
This seems inconsistent and more than a little bizarre. Array.Clear sets all elements of the array to their default values (0, null, whatever), whereas List<>.Clear removes all items from the list. That part makes a reasonable amount of sense, as you can't actually take items away from an Array. However, there doesn't seem to be a way to perform the same operation in one fell swoop on a List<>. For example:
2
1898
by: csharpula csharp | last post by:
Hello, I would like to know what is better for data binding and serialization purposes ArrayList or List<? Thank you! *** Sent via Developersdex http://www.developersdex.com ***
3
3254
by: muquaddim | last post by:
Hello, I have a xml file like the following. <?xml version="1.0"> <data> <idef units="Vin,Vout,E"> <i id="i1"> <sample num="1"> <sampledata value="2;3;7" /> </sample>
4
8929
by: =?Utf-8?B?SkI=?= | last post by:
Hello List<Tis said to be more powerful than ArrayLists but if you have something like this: List<intmylst = new List<>; myList.Add("Joe"); myList.Add(25); the list doesn't seem to accept the name "Joe".
0
8991
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9374
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
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.