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(typeo f(Customer))]
[XmlInlude(typeo f(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.InvalidO perationExcepti on: The type Result may not be used in
this context. at System.Xml.Seri alization.XmlSe rializationWrit er.WriteTypedPr imitive(String
name, String ns, Object o, Boolean xsiType) at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onWriter1.Write 3_Object(String
n, String ns, Object o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onWriter1.Write 7_Result(String
n, String ns, Result o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onWriter1.Write 10_GetSalesProj ectTypesRespons e(Object[]
p) --- End of inner exception stack trace --- at
System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter,
Object o, XmlSerializerNa mespaces namespaces, String encodingStyle) at
System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter,
Object o, XmlSerializerNa mespaces namespaces) at
System.Web.Serv ices.Protocols. SoapServerProto col.WriteReturn s(Object[]
returnValues, Stream outputStream) at
System.Web.Serv ices.Protocols. WebServiceHandl er.WriteReturns (Object[]
returnValues) at System.Web.Serv ices.Protocols. WebServiceHandl er.Invoke()
I also get the same error when trying to just return the CustomerList
and skip the Result object but instead the error says:
System.InvalidO perationExcepti on: The type CustomerList may not be
used in this context.
Please help!!!
//Jonas 1 7264
this example shows how to return an array of "custom objects" http://www.winisp.net/cheeso/srcview...le=Arrays.asmx
-D
"Knecke" <ma*********@te lia.com> wrote in message
news:74******** *************** ***@posting.goo gle.com... 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(typeo f(Customer))] [XmlInlude(typeo f(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.InvalidO perationExcepti on: The type Result may not be used in this context. at
System.Xml.Seri alization.XmlSe rializationWrit er.WriteTypedPr imitive(String name, String ns, Object o, Boolean xsiType) at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onWriter1.Write 3
_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onWriter1.Write 7
_Result(String n, String ns, Result o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.S erialization.Ge neratedAssembly .XmlSerializati onWriter1.Write 1
0_GetSalesProje ctTypesResponse (Object[] p) --- End of inner exception stack trace --- at System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter, Object o, XmlSerializerNa mespaces namespaces, String encodingStyle) at System.Xml.Seri alization.XmlSe rializer.Serial ize(XmlWriter xmlWriter, Object o, XmlSerializerNa mespaces namespaces) at System.Web.Serv ices.Protocols. SoapServerProto col.WriteReturn s(Object[] returnValues, Stream outputStream) at System.Web.Serv ices.Protocols. WebServiceHandl er.WriteReturns (Object[] returnValues) at System.Web.Serv ices.Protocols. WebServiceHandl er.Invoke()
I also get the same error when trying to just return the CustomerList and skip the Result object but instead the error says:
System.InvalidO perationExcepti on: 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, strXMLMessage
|
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 the 'base' class, which may contain an instance of
|
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 method and etc.
However, the proxy created for the webservice contains a definition for this
class without the code I wrote. Instead it contains only public fields. I
understand the reason, interoperability with none .net clients, but is there...
|
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 aynchronously so then in my code I
have this to retrieve the ArrayList object.
public void CalcCallback(IAsyncResult ar)
{
ArrayList arrResults = ws.MyFunction(ar);
}
|
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 having a problem in the calling
program. I searched online and found suggestions that I return an Array
instead so I modified my code (below) to return an Array instead of an
ArrayList. Now I get the message when I try to run just my webservice...
| |
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 viewstate. I had created 4
methods to Add/Remove my special dates in viewstate.
Up to here all seems perfect, but how do I used it in prerender event
for my new calendar control.
|
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 Property1 As String
Public Property2 As Integer
Public Property myCollection1 As Arraylist (Actually, it will be a strongly
|
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 Organization objects which contain the
orgs id, name etc. so they can use that information in the data...
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |