473,408 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Multiplt XmlElementAttribute for WebMethod parameter

Sek
Gurus,

I have a scenario in which two web methods take the same class/struct
as parameter.
The class/struct in turn has two members. The first member being used
by both methods remains as a common data member. The second member is a

"object" such that, it will contain custom data based on the method
being invoked. To put things clear, following is the class i am talking

about:
[XmlTypeAttribute(Namespace="http://xxx")]
public class MessageParams
{
[XmlElementAttribute("Credentials")]
public Credential cred;
[XmlElementAttribute("FirstMethodParam",
typeof(FirstMethodDataType))]
[XmlElementAttribute("SecondMethodParam",
typeof(SecondMethodDataType))]
public object Item;

}
Following are the web methods, i was mentioning:

[WebMethodAttribute()]
[SoapDocumentMethodAttribute(Use=SoapBindingUse.Lit eral,
ParameterStyle=SoapParameterStyle.Bare)]
[return: XmlElementAttribute("MessageReceipt", Namespace="http://xxx")]

public WebResp FirstMethod([XmlElementAttribute("Message")]
MessageParams Message)
{
return new object();

}
[WebMethodAttribute()]
[SoapDocumentMethodAttribute(Use=SoapBindingUse.Lit eral,
ParameterStyle=SoapParameterStyle.Bare)]
[return: XmlElementAttribute("MessageReceipt", Namespace="http://xxx")]

public WebResp SecondMethod([XmlElementAttribute("Message")]
MessageParams Message)
{
return new object();
}
When i build and run the webservice, the XML element for the second
member of "MessageParams" namely "Item" is not serialized and
therefore, doesn't appear in the web services test page. For ex:

Following is the result on the webservice test page. This is NOT the
expected result, as the "FirstMethodParam" element is missing below
"Credentials" element.
<soap:Body>
<MessageParams xmlns="http://xxx">
<Credentials>
<LoginName>string</LoginName>
<Password>string</Password>
<CallerUserID>string</CallerUserID>
</Credentials>
</MessageParams>
</soap:Body>
Following is the expected result, as "FirstMethodParam" is appearing
below "Credentials" element.
<soap:Body>
<MessageParams xmlns="http://XXX">
<Credentials>
<LoginName>string</LoginName>
<Password>string</Password>
<CallerUserID>string</CallerUserID>
</Credentials>
<FirstMethodParam>
<Source/>
<Destination/>
</FirstMethodParam>
</MessageParams>
</soap:Body>
Is this possible under webservices?
TIA.
Sek

Jul 14 '06 #1
1 1406
When i build and run the webservice, the XML element for the second
member of "MessageParams" namely "Item" is not serialized and
therefore, doesn't appear in the web services test page. For ex:
You should make your class IXmlSerializable (well I know it's poorly
documented in .NET Framework documentation libraries) and implement its
methods.

Olivier.

Jul 16 '06 #2

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

Similar topics

2
by: Alin Popovici | last post by:
Hi! I have this problem. I am sending as a parameter for a webmethod a string containing '\r\n' sequences. For some reason, when I debug my webmethod, the paramter is received with the carriage...
24
by: Joseph Geretz | last post by:
Up to this point, our application has been using Windows File Sharing to transfer files to and from our application document repository. This approach does not lend itself toward a secure...
5
by: LS | last post by:
Can a WebMethod return an Interface type? Can we pass an interface parameter ? Example : public interface IEntity { long Id { get; set; } string Name { get; set; } }
2
by: Peter McEvoy | last post by:
Folks, I've been building a Webservice API for a contract that will be exposed to the internet at large. There are two endpoints, and each endpoint contains a number of webmethods. Every...
2
by: MrDotNet | last post by:
Hi I want pass NameValueCollection as parameter in webmethod. I try it but that give me error. Here is Error. You must implement the Add(System.String) method on...
5
by: John | last post by:
Hi Is it possible to pass a whole record to a webmethod? How? Thanks Regards
0
by: Sek | last post by:
Gurus, I have a scenario in which two web methods take the same class/struct as parameter. The class/struct in turn has two members. The first member being used by both methods remains as a...
4
by: =?Utf-8?B?QmlsbEF0V29yaw==?= | last post by:
Hi, We recently converted a 1.1 project to 2.0 and this included a webservice which accepted XML for one of the parameters. Since converting to 2.0 I am getting the following message: --- A...
1
by: chaitanya02 | last post by:
Hello All, Can anyone help me in passing a Datetime parameter to a webmethod, please? *declaration datetime datetime1; webmethod(out string datetime1); is it the right way of declaring a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.