I've created a serializable class and put attributes around all the
properties that should be serialized. I return the class from a web
service, but my problem is that the wsdl for the web service is only
including the Values poperty, and nothing else. Also, when the object gets
serialized out, only the Values property gets serialized. I can't figure
out why.
I've included the serialized output from the webservice and the class code
below:
Webservice serialized return value:
<?xml version="1.0" encoding="utf-8"?>
<Result xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns="http://interiorhealth. ca/teleplan/webbroker">
<Values>
<ValuePart Name="GENDER">M ALE</ValuePart>
<ValuePart Name="RESPONSE" />
<ValuePart Name="MESSAGE" />
<ValuePart Name="TID">000</ValuePart>
<ValuePart Name="Result">S UCCESS</ValuePart>
<ValuePart Name="Filename" >e45.txt</ValuePart>
</Values>
</Result>
class code
[Serializable]
[System.Xml.Seri alization.XmlRo ot(Namespace =
"http://mycomp.com/test")]
public class Result
{
private string strUnParsed_m;
private ValueParts pValues_m;
private Url pRequest_m;
private WebResponse pWebResponse_m;
public enum enResult
{
SUCCESS = 1,
FAILURE = 2,
EXPIRED_PASSWOR D = 3,
UNKNOWN = 4
}
[System.Xml.Seri alization.XmlEl ement("UnParsed ")]
public string UnParsed
{
get
{
return strUnParsed_m;
}
}
public ValueParts Values
{
get
{
return pValues_m;
}
}
[System.Xml.Seri alization.XmlEl ement("Messages ",
IsNullable=true )]
public string Messages
{
get
{
return Values["Msgs"];
}
}
[System.Xml.Seri alization.XmlEl ement("TID")]
public string TID
{
get
{
return Values["TID"];
}
}
[System.Xml.Seri alization.XmlEl ement("ResultTe xt")]
public string ResultText
{
get
{
return Values["Result"];
}
}
[System.Xml.Seri alization.XmlAt tribute("ValidR esult")]
public bool ValidResult
{
get
{
return TID != null && ResultValue != enResult.UNKNOW N;
}
}
[System.Xml.Seri alization.XmlAt tribute("Result Value")]
public enResult ResultValue
{
get
{
string strResult = ResultText.ToLo wer();
if (strResult.Inde xOf("success") == 0)
{
return enResult.SUCCES S;
}
else if (strResult.Inde xOf("failure") == 0)
{
return enResult.FAILUR E;
}
else if (strResult.Inde xOf("expired.pa ssword") == 0)
{
return enResult.EXPIRE D_PASSWORD;
}
else
{
return enResult.UNKNOW N;
}
}
}
[System.Xml.Seri alization.XmlEl ement("FileName ")]
public string FileName
{
get
{
return Values["FileName"];
}
}
[System.Xml.Seri alization.XmlIg nore()]
public WebResponse WebResponse
{
get
{
return pWebResponse_m;
}
}
public Result()
{
...
}
private Result(Url pRequest) : this()
{
...
}
...
[Serializable]
[System.Xml.Seri alization.XmlRo ot("ValueParts" , Namespace =
"http://mycomp.com/test")]
public class ValueParts :
System.Collecti ons.Generic.Lis t<ValuePart>
{
[System.Xml.Seri alization.XmlIg nore()]
public string this[string strName]
{
get
{
FindPart pFindPart = new FindPart(strNam e);
ValuePart pPart = this.Find(pFind Part.CheckMatch );
string strRetVal = string.Empty;
if (pPart != null)
{
strRetVal = pPart.Value;
}
return strRetVal;
}
}
public ValuePart Add(string strName, string strValue)
{
ValuePart pPart = new ValuePart(strNa me, strValue);
this.Add(pPart) ;
return pPart;
}
private class FindPart
{
string strName_m;
public FindPart(string strName)
{
strName_m = strName;
}
public bool CheckMatch(Valu ePart pPart)
{
return strName_m.Equal s(pPart.Name);
}
}
}
[Serializable]
[System.Xml.Seri alization.XmlRo ot("ValuePart" , Namespace =
"http://mycomp.com/test")]
public class ValuePart
{
private string strName_m;
private string stValue_m;
[System.Xml.Seri alization.XmlAt tribute()]
public string Name { get { return strName_m; } set {
strName_m = value; } }
[System.Xml.Seri alization.XmlTe xt()]
public string Value { get { return stValue_m; } set {
stValue_m = value; } }
public ValuePart()
{
}
public ValuePart(strin g strName, string strValue)
{
Name = strName;
Value = strValue;
}
}
}
} 3 2129
"Jeremy" <no****@please. comwrote in
news:O#******** ******@TK2MSFTN GP03.phx.gbl:
I've created a serializable class and put attributes around all the
properties that should be serialized. I return the class from a web
service, but my problem is that the wsdl for the web service is only
including the Values poperty, and nothing else. Also, when the object
gets serialized out, only the Values property gets serialized. I
can't figure out why.
Web services will only serialize public properties. Also in most cases,
readonly properties will not work correctly either. Which properties are
missing?
I've included the serialized output from the webservice and the class
code below:
Webservice serialized return value:
<?xml version="1.0" encoding="utf-8"?>
<Result xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns="http://interiorhealth. ca/teleplan/webbroker">
<Values>
<ValuePart Name="GENDER">M ALE</ValuePart>
<ValuePart Name="RESPONSE" />
<ValuePart Name="MESSAGE" />
<ValuePart Name="TID">000</ValuePart>
<ValuePart Name="Result">S UCCESS</ValuePart>
<ValuePart Name="Filename" >e45.txt</ValuePart>
</Values>
</Result>
class code
[Serializable]
[System.Xml.Seri alization.XmlRo ot(Namespace =
"http://mycomp.com/test")]
public class Result
{
private string strUnParsed_m;
private ValueParts pValues_m;
private Url pRequest_m;
private WebResponse pWebResponse_m;
public enum enResult
{
SUCCESS = 1,
FAILURE = 2,
EXPIRED_PASSWOR D = 3,
UNKNOWN = 4
}
[System.Xml.Seri alization.XmlEl ement("UnParsed ")]
public string UnParsed
{
get
{
return strUnParsed_m;
}
}
public ValueParts Values
{
get
{
return pValues_m;
}
}
[System.Xml.Seri alization.XmlEl ement("Messages ",
IsNullable=true )]
public string Messages
{
get
{
return Values["Msgs"];
}
}
[System.Xml.Seri alization.XmlEl ement("TID")]
public string TID
{
get
{
return Values["TID"];
}
}
[System.Xml.Seri alization.XmlEl ement("ResultTe xt")]
public string ResultText
{
get
{
return Values["Result"];
}
}
[System.Xml.Seri alization.XmlAt tribute("ValidR esult")]
public bool ValidResult
{
get
{
return TID != null && ResultValue !=
enResult.UNKNOW N;
}
}
[System.Xml.Seri alization.XmlAt tribute("Result Value")]
public enResult ResultValue
{
get
{
string strResult = ResultText.ToLo wer();
if (strResult.Inde xOf("success") == 0)
{
return enResult.SUCCES S;
}
else if (strResult.Inde xOf("failure") == 0)
{
return enResult.FAILUR E;
}
else if (strResult.Inde xOf("expired.pa ssword") ==
0) {
return enResult.EXPIRE D_PASSWORD;
}
else
{
return enResult.UNKNOW N;
}
}
}
[System.Xml.Seri alization.XmlEl ement("FileName ")]
public string FileName
{
get
{
return Values["FileName"];
}
}
[System.Xml.Seri alization.XmlIg nore()]
public WebResponse WebResponse
{
get
{
return pWebResponse_m;
}
}
public Result()
{
...
}
private Result(Url pRequest) : this()
{
...
}
...
[Serializable]
[System.Xml.Seri alization.XmlRo ot("ValueParts" , Namespace
=
"http://mycomp.com/test")]
public class ValueParts :
System.Collecti ons.Generic.Lis t<ValuePart>
{
[System.Xml.Seri alization.XmlIg nore()]
public string this[string strName]
{
get
{
FindPart pFindPart = new FindPart(strNam e);
ValuePart pPart =
this.Find(pFind Part.CheckMatch );
string strRetVal = string.Empty;
if (pPart != null)
{
strRetVal = pPart.Value;
}
return strRetVal;
}
}
public ValuePart Add(string strName, string strValue)
{
ValuePart pPart = new ValuePart(strNa me,
strValue); this.Add(pPart) ;
return pPart;
}
private class FindPart
{
string strName_m;
public FindPart(string strName)
{
strName_m = strName;
}
public bool CheckMatch(Valu ePart pPart)
{
return strName_m.Equal s(pPart.Name);
}
}
}
[Serializable]
[System.Xml.Seri alization.XmlRo ot("ValuePart" , Namespace =
"http://mycomp.com/test")]
public class ValuePart
{
private string strName_m;
private string stValue_m;
[System.Xml.Seri alization.XmlAt tribute()]
public string Name { get { return strName_m; } set {
strName_m = value; } }
[System.Xml.Seri alization.XmlTe xt()]
public string Value { get { return stValue_m; } set {
stValue_m = value; } }
public ValuePart()
{
}
public ValuePart(strin g strName, string strValue)
{
Name = strName;
Value = strValue;
}
}
}
}
-- sp**********@ro gers.com (Do not e-mail)
I'm missing everything except for the Values property. I don't understand
why they can't be read only properties, but I'll try making setters for
them.
"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Jeremy" <no****@please. comwrote in
news:O#******** ******@TK2MSFTN GP03.phx.gbl:
>I've created a serializable class and put attributes around all the properties that should be serialized. I return the class from a web service, but my problem is that the wsdl for the web service is only including the Values poperty, and nothing else. Also, when the object gets serialized out, only the Values property gets serialized. I can't figure out why.
Web services will only serialize public properties. Also in most cases,
readonly properties will not work correctly either. Which properties are
missing?
>I've included the serialized output from the webservice and the class code below:
Webservice serialized return value:
<?xml version="1.0" encoding="utf-8"?> <Result xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="htt p://www.w3.org/2001/XMLSchema" xmlns="http://interiorhealth. ca/teleplan/webbroker"> <Values> <ValuePart Name="GENDER">M ALE</ValuePart> <ValuePart Name="RESPONSE" /> <ValuePart Name="MESSAGE" /> <ValuePart Name="TID">000</ValuePart> <ValuePart Name="Result">S UCCESS</ValuePart> <ValuePart Name="Filename" >e45.txt</ValuePart> </Values> </Result>
class code
[Serializable] [System.Xml.Seri alization.XmlRo ot(Namespace = "http://mycomp.com/test")] public class Result { private string strUnParsed_m; private ValueParts pValues_m; private Url pRequest_m; private WebResponse pWebResponse_m;
public enum enResult { SUCCESS = 1, FAILURE = 2, EXPIRED_PASSWOR D = 3, UNKNOWN = 4 }
[System.Xml.Seri alization.XmlEl ement("UnParsed ")] public string UnParsed { get { return strUnParsed_m; } }
public ValueParts Values { get { return pValues_m; } }
[System.Xml.Seri alization.XmlEl ement("Messages ", IsNullable=tru e)] public string Messages { get { return Values["Msgs"]; } }
[System.Xml.Seri alization.XmlEl ement("TID")] public string TID { get { return Values["TID"]; } }
[System.Xml.Seri alization.XmlEl ement("ResultTe xt")] public string ResultText { get { return Values["Result"]; } }
[System.Xml.Seri alization.XmlAt tribute("ValidR esult")] public bool ValidResult { get { return TID != null && ResultValue != enResult.UNKNOW N; } }
[System.Xml.Seri alization.XmlAt tribute("Result Value")] public enResult ResultValue { get { string strResult = ResultText.ToLo wer(); if (strResult.Inde xOf("success") == 0) { return enResult.SUCCES S; } else if (strResult.Inde xOf("failure") == 0) { return enResult.FAILUR E; } else if (strResult.Inde xOf("expired.pa ssword") == 0) { return enResult.EXPIRE D_PASSWORD; } else { return enResult.UNKNOW N; } } }
[System.Xml.Seri alization.XmlEl ement("FileName ")] public string FileName { get { return Values["FileName"]; } }
[System.Xml.Seri alization.XmlIg nore()] public WebResponse WebResponse { get { return pWebResponse_m; } }
public Result() { ... }
private Result(Url pRequest) : this() { ... }
...
[Serializable] [System.Xml.Seri alization.XmlRo ot("ValueParts" , Namespace = "http://mycomp.com/test")] public class ValueParts : System.Collect ions.Generic.Li st<ValuePart> { [System.Xml.Seri alization.XmlIg nore()] public string this[string strName] { get { FindPart pFindPart = new FindPart(strNam e); ValuePart pPart = this.Find(pFind Part.CheckMatch );
string strRetVal = string.Empty;
if (pPart != null) { strRetVal = pPart.Value; } return strRetVal; } }
public ValuePart Add(string strName, string strValue) { ValuePart pPart = new ValuePart(strNa me, strValue); this.Add(pPart) ; return pPart; }
private class FindPart { string strName_m;
public FindPart(string strName) { strName_m = strName; }
public bool CheckMatch(Valu ePart pPart) { return strName_m.Equal s(pPart.Name); } }
}
[Serializable] [System.Xml.Seri alization.XmlRo ot("ValuePart" , Namespace = "http://mycomp.com/test")] public class ValuePart { private string strName_m; private string stValue_m;
[System.Xml.Seri alization.XmlAt tribute()] public string Name { get { return strName_m; } set { strName_m = value; } }
[System.Xml.Seri alization.XmlTe xt()] public string Value { get { return stValue_m; } set { stValue_m = value; } }
public ValuePart() { }
public ValuePart(strin g strName, string strValue) { Name = strName; Value = strValue; } }
}
}
-- sp**********@ro gers.com (Do not e-mail)
"Jeremy" <no****@please. comwrote in
news:#n******** ******@TK2MSFTN GP03.phx.gbl:
I'm missing everything except for the Values property. I don't
understand why they can't be read only properties, but I'll try making
setters for them.
It's a deserialization issue. When .NET deserializes an object, it
instantiates a new instance of the object. If you have read only
properties, it can't deserialize the object correctly (it can't assign
the value passed over from the client).
A simple fix would be to create a blank setter that does nothing. A bit
retarded but it'll fix your serialization issues.
"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
>"Jeremy" <no****@please. comwrote in news:O#******* *******@TK2MSFT NGP03.phx.gbl:
>>I've created a serializable class and put attributes around all the properties that should be serialized. I return the class from a web service, but my problem is that the wsdl for the web service is only including the Values poperty, and nothing else. Also, when the object gets serialized out, only the Values property gets serialized. I can't figure out why.
Web services will only serialize public properties. Also in most cases, readonly properties will not work correctly either. Which properties are missing?
>>I've included the serialized output from the webservice and the class code below:
Webservice serialized return value:
<?xml version="1.0" encoding="utf-8"?> <Result xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="ht tp://www.w3.org/2001/XMLSchema" xmlns="http ://interiorhealth. ca/teleplan/webbroker"> <Values> <ValuePart Name="GENDER">M ALE</ValuePart> <ValuePart Name="RESPONSE" /> <ValuePart Name="MESSAGE" /> <ValuePart Name="TID">000</ValuePart> <ValuePart Name="Result">S UCCESS</ValuePart> <ValuePart Name="Filename" >e45.txt</ValuePart> </Values> </Result>
class code
[Serializable] [System.Xml.Seri alization.XmlRo ot(Namespace = "http://mycomp.com/test")] public class Result { private string strUnParsed_m; private ValueParts pValues_m; private Url pRequest_m; private WebResponse pWebResponse_m;
public enum enResult { SUCCESS = 1, FAILURE = 2, EXPIRED_PASSWOR D = 3, UNKNOWN = 4 }
[System.Xml.Seri alization.XmlEl ement("UnParsed ")] public string UnParsed { get { return strUnParsed_m; } }
public ValueParts Values { get { return pValues_m; } }
[System.Xml.Seri alization.XmlEl ement("Messages ", IsNullable=tr ue)] public string Messages { get { return Values["Msgs"]; } }
[System.Xml.Seri alization.XmlEl ement("TID")] public string TID { get { return Values["TID"]; } }
[System.Xml.Seri alization.XmlEl ement("ResultTe xt")] public string ResultText { get { return Values["Result"]; } }
[System.Xml.Seri alization.XmlAt tribute("ValidR esult")] public bool ValidResult { get { return TID != null && ResultValue != enResult.UNKNOW N; } }
[System.Xml.Seri alization.XmlAt tribute("Result Value")] public enResult ResultValue { get { string strResult = ResultText.ToLo wer(); if (strResult.Inde xOf("success") == 0) { return enResult.SUCCES S; } else if (strResult.Inde xOf("failure") == 0) { return enResult.FAILUR E; } else if (strResult.Inde xOf("expired.pa ssword") == 0) { return enResult.EXPIRE D_PASSWORD; } else { return enResult.UNKNOW N; } } }
[System.Xml.Seri alization.XmlEl ement("FileName ")] public string FileName { get { return Values["FileName"]; } }
[System.Xml.Seri alization.XmlIg nore()] public WebResponse WebResponse { get { return pWebResponse_m; } }
public Result() { ... }
private Result(Url pRequest) : this() { ... }
...
[Serializable] [System.Xml.Seri alization.XmlRo ot("ValueParts" , Namespace = "http://mycomp.com/test")] public class ValueParts : System.Collec tions.Generic.L ist<ValuePart> { [System.Xml.Seri alization.XmlIg nore()] public string this[string strName] { get { FindPart pFindPart = new FindPart(strNam e); ValuePart pPart = this.Find(pFind Part.CheckMatch );
string strRetVal = string.Empty;
if (pPart != null) { strRetVal = pPart.Value; } return strRetVal; } }
public ValuePart Add(string strName, string strValue) { ValuePart pPart = new ValuePart(strNa me, strValue); this.Add(pPart) ; return pPart; }
private class FindPart { string strName_m;
public FindPart(string strName) { strName_m = strName; }
public bool CheckMatch(Valu ePart pPart) { return strName_m.Equal s(pPart.Name); } }
}
[Serializable] [System.Xml.Seri alization.XmlRo ot("ValuePart" , Namespace = "http://mycomp.com/test")] public class ValuePart { private string strName_m; private string stValue_m;
[System.Xml.Seri alization.XmlAt tribute()] public string Name { get { return strName_m; } set { strName_m = value; } }
[System.Xml.Seri alization.XmlTe xt()] public string Value { get { return stValue_m; } set { stValue_m = value; } }
public ValuePart() { }
public ValuePart(strin g strName, string strValue) { Name = strName; Value = strValue; } }
}
}
-- sp**********@ro gers.com (Do not e-mail)
-- sp**********@ro gers.com (Do not e-mail) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jakob Bengtsson |
last post by:
Hi,
I have a form (which cannot be serialized).
In the form's code I declare an object like this (never
mind the object nor class name, it's for illustration
only):
Private WithEvents eventPublisher as EventPublisherClass
|
by: Rein Petersen |
last post by:
Hi Folks!
Here's a strange behaviour:
Without a properties SET accessor (see code below), the property will not
serialize.
public class myObject
{
|
by: Tobias Zimmergren |
last post by:
Hi, just wondering what serializing really is, and howto use it?
Thanks.
Tobias
__________________________________________________________________ Tobias
ICQ#: 55986339 Current ICQ status: + More ways to contact me
__________________________________________________________________
|
by: umhlali |
last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem serializing the object but there seems to be a problem serializing an array of objects. Any help will be appreciated
"Cannot assign object of type System.Object to an object of type ElectronicWallet.C2PTest.PaymentItem."
:...
|
by: Picho |
last post by:
Hi all.
I have a webservice and a windows app.
both of them reference the same class library called WebServiceTest.Core
that defines a class called Class1.
the webservice exposes a method that looks like this:
public WebServiceTest.Core.Class1 GetClass1()
| |
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.
|
by: axr |
last post by:
Having trouble with Serilization of objects that contain members which are of
type Interface
eg
public class SomeClass
{
ISomeInterface1 itf1;
ClassType1 ct1;
ISomeInterface2 itf2;
|
by: dmjpro |
last post by:
plz send me a good link which can clearify me how the J2EE framework works
i want the details information .... plz help
thanx
|
by: she_prog |
last post by:
I have a class derived from UserControl.
I need to serialize an object of this class, but only some properties
of it, as not all properties are serializable (some of the properties
coming from UserControl are like that). When serializing, how
could I ignore all the properties coming from the UserControl
class? I know there is XmlIgnoreAttribute, but how could I set it
to every property of UserControl, as it is not my class?
Thank you...
|
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...
|
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: 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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |