Hi all.
I have a problem with returning a custom Result object with
webservice.
The classes i use is described below (some fields and properties is
removed)
public class Result {
int statusCode;
object data;
}
public class Customer {
int customerNr
}
public class CustomerList : ArrayList {
//Implements the add method to only add Customer objects
}
And now to the webmethod
[WebMethod]
[XmlInlude(typeof(Customer))]
[XmlInlude(typeof(CustomerList))]
public Result GetCustomers() {
//Logic to find the customer is placed here....
//All the customers is placed in a variable called custList
res.data = custList;
res.statusCode = 1;
return res;
}
Now, when running this, this errormessage appears:
System.InvalidOperationException: The type Result may not be used in
this context. at System.Xml.Serialization.XmlSerializationWriter.Wr iteTypedPrimitive(String
name, String ns, Object o, Boolean xsiType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write3_Object(String
n, String ns, Object o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write7_Result(String
n, String ns, Result o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write10_GetSalesProjectTypesRe sponse(Object[]
p) --- End of inner exception stack trace --- at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle) at
System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces) at
System.Web.Services.Protocols.SoapServerProtocol.W riteReturns(Object[]
returnValues, Stream outputStream) at
System.Web.Services.Protocols.WebServiceHandler.Wr iteReturns(Object[]
returnValues) at System.Web.Services.Protocols.WebServiceHandler.In voke()
I also get the same error when trying to just return the CustomerList
and skip the Result object but instead the error says:
System.InvalidOperationException: The type CustomerList may not be
used in this context.
Please help!!!
//Jonas 1 7242
this example shows how to return an array of "custom objects" http://www.winisp.net/cheeso/srcview...le=Arrays.asmx
-D
"Knecke" <ma*********@telia.com> wrote in message
news:74**************************@posting.google.c om... Hi all.
I have a problem with returning a custom Result object with webservice.
The classes i use is described below (some fields and properties is removed)
public class Result { int statusCode; object data; }
public class Customer { int customerNr }
public class CustomerList : ArrayList { //Implements the add method to only add Customer objects }
And now to the webmethod
[WebMethod] [XmlInlude(typeof(Customer))] [XmlInlude(typeof(CustomerList))] public Result GetCustomers() { //Logic to find the customer is placed here.... //All the customers is placed in a variable called custList
res.data = custList; res.statusCode = 1;
return res; }
Now, when running this, this errormessage appears:
System.InvalidOperationException: The type Result may not be used in this context. at
System.Xml.Serialization.XmlSerializationWriter.Wr iteTypedPrimitive(String name, String ns, Object o, Boolean xsiType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write3
_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write7
_Result(String n, String ns, Result o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriter1.Write1
0_GetSalesProjectTypesResponse(Object[] p) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle) at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces) at System.Web.Services.Protocols.SoapServerProtocol.W riteReturns(Object[] returnValues, Stream outputStream) at System.Web.Services.Protocols.WebServiceHandler.Wr iteReturns(Object[] returnValues) at System.Web.Services.Protocols.WebServiceHandler.In voke()
I also get the same error when trying to just return the CustomerList and skip the Result object but instead the error says:
System.InvalidOperationException: The type CustomerList may not be used in this context.
Please help!!!
//Jonas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave H |
last post by:
Hi everyone,
I'm trying to access a webservice (asmx) from an asp page and I'm having a
problem with the load below:
<%
Dim dblTax, strQuery, objRequest, objXMLDoc, strXMLwsURL,...
|
by: Toby Mathews |
last post by:
Hi there
I am trying to return an instance of a class from a web service that
contains a collection of instances of another class. I have three classes:
Person
MyEmails
MyEmail
Person is...
|
by: Ohad Young |
last post by:
Hi,
I have a webservice method that returns an instance of a custom class I
created (e.g., bank account).
The class definition in the webservice contains properties, overrides
Object.ToString...
|
by: SteveR |
last post by:
I want to return an ArrayList from my web service. I can write this part and
everything compiles but I can't get the web application that uses the web
service to compile. I call the service...
|
by: Stacey Levine |
last post by:
I have a webservice that I wanted to return an ArrayList..Well the service
compiles and runs when I have the output defined as ArrayList, but the WSDL
defines the output as an Object so I was...
|
by: rushikesh.joshi |
last post by:
Hi All,
I want to create custom control by using Web.UI.WebControls.Calendar,
in which I want to set few days with different color. I had created two
property to set the color and storing in...
|
by: Asim Qazi |
last post by:
Hi All
public class MyResponse
{
public bool m_bStatus;
public string m_szErrorCode;
public string m_szMessage;
}
|
by: =?Utf-8?B?Y3Nz?= |
last post by:
I am new to ASP.net webservice and have a quesiton.
Is is possible to pass custom object to a web service (using VB 2005)? My
custom object will look like this
Public Class Myclass
Public...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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...
| |