473,382 Members | 1,563 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,382 software developers and data experts.

XML as parameter to a method

Is it possible to have a method that accepts XML document (including
processing instruction at top and the root node) as a parameter? Does this
parameter need to be defined as type string?

I have been given an XML structure to be used in a method call and I am not
sure if I should convert that into a C# struct to be used as a parameter
type and if so how. The specification says something like ... The input will
be an XML such as ...

<?xml ... ?>
<root>
<etc etc />
</root>

Please help.
Nov 21 '05 #1
6 1332
> Is it possible to have a method that accepts XML document (including
processing instruction at top and the root node) as a parameter?
Yes, except you can't have the ?xml? PI because there's only one of those allowed per document and the SOAP message is itself a document. You shouldn't need the PI if you think about it.
Does
this parameter need to be defined as type string?
Noooooo, definitely not. Your web method signature need simply be something to the effect of:

public void MyWebMethod([XmlElement("nameOfYourRootElement", Namespace="uri:somenamespaceuri")] XmlElement rootElement)
{
.... use rootElement here ...
}
I have been given an XML structure to be used in a method call and I
am not sure if I should convert that into a C# struct to be used as a
parameter type and if so how. The specification says something like
... The input will be an XML such as ...

<?xml ... ?>
<root>
<etc etc />
</root>


Well everything's ok except for the ?xml? PI. Whoever said that has to be the spec should be questioned about it because they should know that that particular PI isn't allowed to be defined twice and, when it is defined, it must be the first line of any XML document instance. Since the SOAP envelope itself is XML, it already contains this PI. Therefore it should not be needed on your parameter.

HTH,
Drew
Nov 21 '05 #2
One way to do this is to define the parameter as an encoded string. This
isn't optimal since the entire document will be byte encoded on the wire to
get around the angle brackets, etc. This equates to a CDATA region in an
XML schema. Not pretty, not recommended. If you really need to be able to
post an XML document, you might want to just handle the XML directly from
an HTTP filter or an XML data island within a web page.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "Tushar" <xx*************@CODA.com>
Subject: XML as parameter to a method
Date: Fri, 26 Nov 2004 17:04:49 -0000
Lines: 17
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <#s**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: 213.146.159.254
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7654
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Is it possible to have a method that accepts XML document (including
processing instruction at top and the root node) as a parameter? Does this
parameter need to be defined as type string?

I have been given an XML structure to be used in a method call and I am not
sure if I should convert that into a C# struct to be used as a parameter
type and if so how. The specification says something like ... The input will
be an XML such as ...

<?xml ... ?>
<root>
<etc etc />
</root>

Please help.

Nov 21 '05 #3
XML Data Island?!?!?!?!?

"Dan Rogers" <da***@microsoft.com> wrote in message news:uF**************@cpmsftngxa10.phx.gbl...
One way to do this is to define the parameter as an encoded string. This
isn't optimal since the entire document will be byte encoded on the wire to
get around the angle brackets, etc. This equates to a CDATA region in an
XML schema. Not pretty, not recommended. If you really need to be able to
post an XML document, you might want to just handle the XML directly from
an HTTP filter or an XML data island within a web page.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "Tushar" <xx*************@CODA.com>
Subject: XML as parameter to a method
Date: Fri, 26 Nov 2004 17:04:49 -0000
Lines: 17
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <#s**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: 213.146.159.254
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7654
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Is it possible to have a method that accepts XML document (including
processing instruction at top and the root node) as a parameter? Does this
parameter need to be defined as type string?

I have been given an XML structure to be used in a method call and I am not
sure if I should convert that into a C# struct to be used as a parameter
type and if so how. The specification says something like ... The input will
be an XML such as ...

<?xml ... ?>
<root>
<etc etc />
</root>

Please help.

Nov 21 '05 #4
I just don't know what a Data Island is :)

"Dan Rogers" <da***@microsoft.com> wrote in message news:b5**************@cpmsftngxa10.phx.gbl...
Hi Scott,

I only mention this kind of approach because it seems that your
requirements much more closely fit, from what little I know, a traditional
ASP page approach (or plain old HTTP).

Does this make sense?

Dan
--------------------
Reply-To: "Scott Meddows" <sc******************@tsged-removeme.com>
From: "Scott Meddows" <sc******************@tsged-removeme.com>
References: <#s**************@TK2MSFTNGP15.phx.gbl>
<uF**************@cpmsftngxa10.phx.gbl>
Subject: Re: XML as parameter to a method
Date: Thu, 2 Dec 2004 12:00:22 -0600
Lines: 53
Organization: The Schumacher Group
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#w**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: laf3662-nat2.tsged.com 209.215.85.43
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7752
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

XML Data Island?!?!?!?!?

"Dan Rogers" <da***@microsoft.com> wrote in message
news:uF**************@cpmsftngxa10.phx.gbl...
One way to do this is to define the parameter as an encoded string. This
isn't optimal since the entire document will be byte encoded on the wire

to
get around the angle brackets, etc. This equates to a CDATA region in an
XML schema. Not pretty, not recommended. If you really need to be able

to
post an XML document, you might want to just handle the XML directly from
an HTTP filter or an XML data island within a web page.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "Tushar" <xx*************@CODA.com>
Subject: XML as parameter to a method
Date: Fri, 26 Nov 2004 17:04:49 -0000
Lines: 17
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <#s**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: 213.146.159.254
Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7654
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Is it possible to have a method that accepts XML document (including
processing instruction at top and the root node) as a parameter? Does this
parameter need to be defined as type string?

I have been given an XML structure to be used in a method call and I am

not
sure if I should convert that into a C# struct to be used as a parameter
type and if so how. The specification says something like ... The input

will
be an XML such as ...

<?xml ... ?>
<root>
<etc etc />
</root>

Please help.


Nov 21 '05 #5
Ahh. It was a technique for embedding XML islands within ASP pages and
having script on the client side process the XML. It basically had the
server putting XML into a span, and then the script on the client side
reading that XMl and using it to display dynamic content.
--------------------
Reply-To: "Scott Meddows" <sc******************@tsged-removeme.com>
From: "Scott Meddows" <sc******************@tsged-removeme.com>
References: <#s**************@TK2MSFTNGP15.phx.gbl>
<uF**************@cpmsftngxa10.phx.gbl>
<#w**************@TK2MSFTNGP15.phx.gbl>
<b5**************@cpmsftngxa10.phx.gbl>
Subject: Re: XML as parameter to a method
Date: Fri, 3 Dec 2004 11:11:34 -0600
Lines: 98
Organization: The Schumacher Group
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#X**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: laf3662-nat2.tsged.com 209.215.85.43
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10
.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7801
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I just don't know what a Data Island is :)

"Dan Rogers" <da***@microsoft.com> wrote in message
news:b5**************@cpmsftngxa10.phx.gbl...
Hi Scott,

I only mention this kind of approach because it seems that your
requirements much more closely fit, from what little I know, a traditional
ASP page approach (or plain old HTTP).

Does this make sense?

Dan
--------------------
Reply-To: "Scott Meddows" <sc******************@tsged-removeme.com>
From: "Scott Meddows" <sc******************@tsged-removeme.com>
References: <#s**************@TK2MSFTNGP15.phx.gbl>
<uF**************@cpmsftngxa10.phx.gbl>
Subject: Re: XML as parameter to a method
Date: Thu, 2 Dec 2004 12:00:22 -0600
Lines: 53
Organization: The Schumacher Group
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#w**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: laf3662-nat2.tsged.com 209.215.85.43
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15 phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7752
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

XML Data Island?!?!?!?!?

"Dan Rogers" <da***@microsoft.com> wrote in message
news:uF**************@cpmsftngxa10.phx.gbl...
One way to do this is to define the parameter as an encoded string. This
isn't optimal since the entire document will be byte encoded on the wire

to
get around the angle brackets, etc. This equates to a CDATA region in an
XML schema. Not pretty, not recommended. If you really need to be able

to
post an XML document, you might want to just handle the XML directly from
an HTTP filter or an XML data island within a web page.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "Tushar" <xx*************@CODA.com>
Subject: XML as parameter to a method
Date: Fri, 26 Nov 2004 17:04:49 -0000
Lines: 17
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <#s**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: 213.146.159.254
Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7654
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Is it possible to have a method that accepts XML document (including
processing instruction at top and the root node) as a parameter? Does this parameter need to be defined as type string?

I have been given an XML structure to be used in a method call and I am

not
sure if I should convert that into a C# struct to be used as a parameter
type and if so how. The specification says something like ... The input

will
be an XML such as ...

<?xml ... ?>
<root>
<etc etc />
</root>

Please help.



Nov 21 '05 #6
Ahhh, check!

"Dan Rogers" <da***@microsoft.com> wrote in message news:aA**************@cpmsftngxa10.phx.gbl...
Ahh. It was a technique for embedding XML islands within ASP pages and
having script on the client side process the XML. It basically had the
server putting XML into a span, and then the script on the client side
reading that XMl and using it to display dynamic content.
--------------------
Reply-To: "Scott Meddows" <sc******************@tsged-removeme.com>
From: "Scott Meddows" <sc******************@tsged-removeme.com>
References: <#s**************@TK2MSFTNGP15.phx.gbl>
<uF**************@cpmsftngxa10.phx.gbl>
<#w**************@TK2MSFTNGP15.phx.gbl>
<b5**************@cpmsftngxa10.phx.gbl>
Subject: Re: XML as parameter to a method
Date: Fri, 3 Dec 2004 11:11:34 -0600
Lines: 98
Organization: The Schumacher Group
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#X**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: laf3662-nat2.tsged.com 209.215.85.43
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7801
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I just don't know what a Data Island is :)

"Dan Rogers" <da***@microsoft.com> wrote in message
news:b5**************@cpmsftngxa10.phx.gbl...
Hi Scott,

I only mention this kind of approach because it seems that your
requirements much more closely fit, from what little I know, a traditional
ASP page approach (or plain old HTTP).

Does this make sense?

Dan
--------------------
Reply-To: "Scott Meddows" <sc******************@tsged-removeme.com>
From: "Scott Meddows" <sc******************@tsged-removeme.com>
References: <#s**************@TK2MSFTNGP15.phx.gbl>
<uF**************@cpmsftngxa10.phx.gbl>
Subject: Re: XML as parameter to a method
Date: Thu, 2 Dec 2004 12:00:22 -0600
Lines: 53
Organization: The Schumacher Group
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#w**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: laf3662-nat2.tsged.com 209.215.85.43
Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7752
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

XML Data Island?!?!?!?!?

"Dan Rogers" <da***@microsoft.com> wrote in message
news:uF**************@cpmsftngxa10.phx.gbl...
One way to do this is to define the parameter as an encoded string. This
isn't optimal since the entire document will be byte encoded on the wire

to
get around the angle brackets, etc. This equates to a CDATA region in an
XML schema. Not pretty, not recommended. If you really need to be able

to
post an XML document, you might want to just handle the XML directly from
an HTTP filter or an XML data island within a web page.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "Tushar" <xx*************@CODA.com>
Subject: XML as parameter to a method
Date: Fri, 26 Nov 2004 17:04:49 -0000
Lines: 17
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <#s**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: 213.146.159.254
Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7654
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Is it possible to have a method that accepts XML document (including
processing instruction at top and the root node) as a parameter? Does this parameter need to be defined as type string?

I have been given an XML structure to be used in a method call and I am

not
sure if I should convert that into a C# struct to be used as a parameter
type and if so how. The specification says something like ... The input

will
be an XML such as ...

<?xml ... ?>
<root>
<etc etc />
</root>

Please help.



Nov 23 '05 #7

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

Similar topics

8
by: Dave Veeneman | last post by:
Can I pass a method pass one of its out parameters to another method? C# is telling me I can't. Let's say I have two methods, FooManager and FooWorker. FooManager is part of a class that acts as...
4
by: Ben Blair | last post by:
Hi. How does one assign a custom parameter attribute to the implicit "value" parameter of the set accessor method of a property? For example, I can assign a custom attribute to the return...
5
by: Jet | last post by:
Hi all, I had a code like the follow: class A{ ... public void get(int i,params OleDbParameter p) { if((p!=null)||(p.Length>0)) { // Do some work }
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
20
by: Brien King | last post by:
If I have a parameter that has an Object type (as opposed to something like a string), can I make that parameter a CONST? Right now, if you pass an object into a sub/function, that sub/function...
3
by: JohnnyGr | last post by:
I have heard theres a new way to start threads with parameters in framework 2.0, does anyone know how to do that? this is what i need to do... Start a thread that executes some stuff, in this...
3
by: Pratcp | last post by:
Hello, I have an asp.net Web app in vb.net trying to call a C# web service which takes a reference parameter. I tried a simple C# web app to call the Web service and it works perfectly. However,...
11
by: dahuzizyd | last post by:
Hi all: I think I had a problem with using out parameter , why the instance of 'SubClass' can't convert to 'BaseClass' ? my code is : ---------------------------------------------- using System;...
2
by: ME | last post by:
How would one obtain the parameter VALUES of a method that has already run? I can find the method using the StackTrace and StackFrame classes but once I find the method I would like to obtain the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
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...
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...

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.