473,399 Members | 2,858 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,399 software developers and data experts.

Pass in XML to WebService Method?

I have the following xml Schema:

“<?xml version="1.0" encoding="Windows-1252"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Document">
<xs:complexType>
<xs:sequence>
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="Folder">
<xs:complexType>
<xs:sequence>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="Folder" />
<xs:element ref="Document" />
</xs:sequence>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>”

I want to pass xml documents into a web service that conforms to this
schema. What I have tried to do is use the xsd /c tool to produce a class
based on the schema then have a method definition as follows:

[WebMethod]
public bool test(Folder test)
{
return true;
}

This only allows me to pass in a folder containing one document. The schema
allows for each folder to contain any number of folders or documents. What
can I do to enable this to work?

Thanks

Jan 28 '07 #1
4 2251
Hello Nick,

According to the XML Schema you mentioned, I have performed some test on my
local side. It seems the XSD tool will generate the following class
(through xsd.exe /classes schamefile). And the generated Folder class
contains a "Document" and a "Folder1" property. However, both of the two
properties are of Array type. So you can add multiple Documents and Folders
instance as children of a Folder instance. This doesn't violate the XSD
schema you provided. Is this what you get in your test project also?

===================
public partial class Folder {

private Folder[] folder1Field;

private Document[] documentField;

private string nameField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Fold er")]
public Folder[] Folder1 {
get {
return this.folder1Field;
}
set {
this.folder1Field = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Docu ment")]
public Document[] Document {
get {
return this.documentField;
}
set {
this.documentField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
}

============================
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jan 29 '07 #2
Thanks for replying. That is exactly what I get with the XSD tool. My issue
is with using the following web service with a windows forms application:
“[WebMethod]
public bool test(Folder test)
{
return true;
}”
By creating a new windows forms project and adding a web reference to this
service, I am unable to pass in a folder that contains multiple sub folders:
“WebReference.Service wr = new WebReference.Service();

WebReference.Folder Folder1 = new WebReference.Folder();”
How would I create sub folders / documents?

Thanks
"Steven Cheng[MSFT]" wrote:
Hello Nick,

According to the XML Schema you mentioned, I have performed some test on my
local side. It seems the XSD tool will generate the following class
(through xsd.exe /classes schamefile). And the generated Folder class
contains a "Document" and a "Folder1" property. However, both of the two
properties are of Array type. So you can add multiple Documents and Folders
instance as children of a Folder instance. This doesn't violate the XSD
schema you provided. Is this what you get in your test project also?

===================
public partial class Folder {

private Folder[] folder1Field;

private Document[] documentField;

private string nameField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Fold er")]
public Folder[] Folder1 {
get {
return this.folder1Field;
}
set {
this.folder1Field = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Docu ment")]
public Document[] Document {
get {
return this.documentField;
}
set {
this.documentField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
}

============================
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights
Jan 29 '07 #3
From the generated class defintion of Folder, it has a Folder1 property of
type Folder[], and a Document property of type Document[].

Say you want to pass the contents of C.

WebReference.Folder myCDrive = new WebReference.Folder();

myCDrive.Folder1 = GetSubDirs("c");
myCDrive.Documents = GetFiles("c");

Where GetSubDirs() is a helper method, using System.IO.Directory class to
get directories, and transform the lot to WebReference.Folder[], and same
for GetFiles().

So now the myCDrive object, which is a top level view of the C directory,
has all subdirs and documents in that folder.

Use recursive directory listing code to populate all the subdirs down to a
specified nesting level if necessary.

Ron

"nickname" <ni*******@newsgroups.nospamwrote in message
news:1C**********************************@microsof t.com...
Thanks for replying. That is exactly what I get with the XSD tool. My
issue
is with using the following web service with a windows forms application:
"[WebMethod]
public bool test(Folder test)
{
return true;
}"
By creating a new windows forms project and adding a web reference to this
service, I am unable to pass in a folder that contains multiple sub
folders:
"WebReference.Service wr = new WebReference.Service();

WebReference.Folder Folder1 = new WebReference.Folder();"
How would I create sub folders / documents?

Thanks
"Steven Cheng[MSFT]" wrote:
>Hello Nick,

According to the XML Schema you mentioned, I have performed some test on
my
local side. It seems the XSD tool will generate the following class
(through xsd.exe /classes schamefile). And the generated Folder class
contains a "Document" and a "Folder1" property. However, both of the two
properties are of Array type. So you can add multiple Documents and
Folders
instance as children of a Folder instance. This doesn't violate the XSD
schema you provided. Is this what you get in your test project also?

===================
public partial class Folder {

private Folder[] folder1Field;

private Document[] documentField;

private string nameField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Fold er")]
public Folder[] Folder1 {
get {
return this.folder1Field;
}
set {
this.folder1Field = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Docu ment")]
public Document[] Document {
get {
return this.documentField;
}
set {
this.documentField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
}

============================
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

================================================= =

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

================================================= =

This posting is provided "AS IS" with no warranties, and confers no
rights

Jan 29 '07 #4
Thanks for Ron's input.

Hi Nick,

As Ron mentioned, you can provide multiple subfoldes to the "Folder1"
property, and multiple documents to the "Document" property. e.g

==================
static void SimpleTest()
{
TestService.Service ts = new Service();

Folder folder = new Folder();
folder.name = "root_folder1";

Folder[] subfolders = new Folder[3];
subfolders[0] = new Folder();
subfolders[1] = new Folder();
subfolders[2] = new Folder();

folder.Folder1 = subfolders;

Document[] documents = new Document[3];
documents[0] = new Document();
documents[1] = new Document();
documents[2] = new Document();

folder.Document = documents;
string ret = ts.SendFolder(folder);
..........
}
=====================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
Jan 30 '07 #5

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

Similar topics

11
by: Andy | last post by:
Make the story short, I have a VB.NET client interface calling .NET webservice, written in VB.NET as well. I am trying to make the client as thin as possible so I let the webservice part to...
5
by: AliR | last post by:
Hi Everyone, I have a Visual C++ MFC program, and I am trying to use a webservice written in C#. When I add the webservice to my project using Add Web Reference the sproxy compiler complains...
0
by: batista | last post by:
Hi, I'm using webservice.htc to call a non-secure(without https) webservice method from a webpage. Now, if the webpage is not under https then everything works fine. But, when enable ssl in...
1
by: Christian Havel | last post by:
Hi, how can I pass a ICollection as a return value from a Webservice method? Thanks Christian
2
by: Deecrypt | last post by:
Hi, I'm a newbie to the Web Services topic. I have an ASP.NET website and am trying to send a Dataset from it to a WebService which should insert all the data from this DataSet to an Access...
0
by: raghuraman_ace | last post by:
Hi i have started a webservice wich has a webmethod with parameters using literal encoding & encoded encoding . The webservice is compiled successfully . But i don know how to pass the...
5
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into...
0
by: francovincent | last post by:
I am creatting webservice proxy in C++ dll to consume a webservice. But i am not able to pass credentials to that . Can anyone help me on this? I am setting the url of the webservice with...
1
by: parimalb | last post by:
Hi All, I want to pass an array argument to the java webservice from perl client using SOAP::LITE package. Please let me know if anyone knows about this. The web method declaration in java is...
4
by: Jonathan | last post by:
I have a SQL stored procedure for adding a new record in a transactions table. It also has two return values: CounterID and IDKey. I want to create a webservice that accepts the 10 input...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
jinu1996
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...
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 projectplanning, coding, testing,...

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.