468,107 Members | 1,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

Web service parameters

Hi all,

I am creating a web service which takes in a bulk of training text for
each of two authors, along with a third bulk of anonymous text, and
predicts which author is most likely to have written the anonymous
text.

I have no experience with web services and I am confused about the
best way to design this - particularly with regards to the parameters
that the service is passed.

Before the service is invoked, the text is loaded through the client.
The anonymous text is simple - just a single text file. However, for
each author, there will be between 2 and 10 text documents, which
constitute the author's training work. It is important that these
documents remain as individual documents. Each document could be up to
half a MB in size.

What is the best way of getting all of this information to the web
service? Should each document be transmitted as an array of strings
perhaps? Or is there a way of sending the document as a standard text
file, unaltered?

The functionality for this is already written in a Windows forms
application I created. This existing application treats each document
as a special trainingDocument class. However, I don't think the web
service could use this, could it? Because each user wanting to consume
the service would then have to create a set of trainingDocument
objects first.

Am I correct in thinking that the best parameters for a web service
are your basic int, string etc primitive types, to ensure wide
compatability?

Any advice would be very much appreciated.

Matt
Apr 10 '06 #1
5 1284
Hello Matt,

The solution depends wether you want to keep the original files of the
authors as they were delivered. I you want to keep them this might not be
compatible with other enviroments and might raise some dificulties. If you
will not keep them you will lose the formating properties of the text.
If you can allow to lose the formating of the text, I will recomend you to
use the trainingDocument class in the webservice, and build it to a different
assembly that can be distributed to your client.
If you prefare there is an even simpler way. You can use the include
attribute to include the trainingDocument type in the webservice. This way
users can use the wsdl tool of microsoft (either manually or by using web
reference) to create the trainingDocument class and use it in the web service.
--
GuyBar
"Matt B" wrote:
Hi all,

I am creating a web service which takes in a bulk of training text for
each of two authors, along with a third bulk of anonymous text, and
predicts which author is most likely to have written the anonymous
text.

I have no experience with web services and I am confused about the
best way to design this - particularly with regards to the parameters
that the service is passed.

Before the service is invoked, the text is loaded through the client.
The anonymous text is simple - just a single text file. However, for
each author, there will be between 2 and 10 text documents, which
constitute the author's training work. It is important that these
documents remain as individual documents. Each document could be up to
half a MB in size.

What is the best way of getting all of this information to the web
service? Should each document be transmitted as an array of strings
perhaps? Or is there a way of sending the document as a standard text
file, unaltered?

The functionality for this is already written in a Windows forms
application I created. This existing application treats each document
as a special trainingDocument class. However, I don't think the web
service could use this, could it? Because each user wanting to consume
the service would then have to create a set of trainingDocument
objects first.

Am I correct in thinking that the best parameters for a web service
are your basic int, string etc primitive types, to ensure wide
compatability?

Any advice would be very much appreciated.

Matt

Apr 11 '06 #2
On Tue, 11 Apr 2006 02:01:01 -0700, guybar
<gu****@discussions.microsoft.com> wrote:
Hello Matt,

The solution depends wether you want to keep the original files of the
authors as they were delivered. I you want to keep them this might not be
compatible with other enviroments and might raise some dificulties. If you
will not keep them you will lose the formating properties of the text.
If you can allow to lose the formating of the text, I will recomend you to
use the trainingDocument class in the webservice, and build it to a different
assembly that can be distributed to your client.
If you prefare there is an even simpler way. You can use the include
attribute to include the trainingDocument type in the webservice. This way
users can use the wsdl tool of microsoft (either manually or by using web
reference) to create the trainingDocument class and use it in the web service.


Guy, thanks, that's really helpful.

Let me check I've understood this correctly - if I add the
trainingDocument class to the web service, users of the service can
use it to create trainingDocument objects that they can then pass to
the [Webmethod] doing the work. They will be able to do this by adding
a web reference within the client.

Could you give me some more information on this, please?
Say, I have the following:

[WebMethod]
public int AttributeAuthorship ( TrainingDocument [] authorA,
TrainingDocument [] authorB, TrainingDocument anonDoc )
{
// Code to attribute authorship

return authorID;
}
And I have a separate class as a TrainingDocument.cs file:
public class TrainingDocument
{
Attributes...

public TrainingDocument()
{
// Constructor code
}

further methods...
}
How do I add the TrainingDocument class to the web service so that
users can create objects from the class when creating the client?

Matt
Apr 11 '06 #3
Hi Matt,

All you need to do is add the include attribute to the webservice
decleration, as follows:

[WebMethod]
[XmlInclude(typeof(TrainingDocument))]
public int AttributeAuthorship ( TrainingDocument [] authorA,
TrainingDocument [] authorB, TrainingDocument anonDoc )
{
// Code to attribute authorship

return authorID;
}
--
GuyBar
"Matt B" wrote:
On Tue, 11 Apr 2006 02:01:01 -0700, guybar
<gu****@discussions.microsoft.com> wrote:
Hello Matt,

The solution depends wether you want to keep the original files of the
authors as they were delivered. I you want to keep them this might not be
compatible with other enviroments and might raise some dificulties. If you
will not keep them you will lose the formating properties of the text.
If you can allow to lose the formating of the text, I will recomend you to
use the trainingDocument class in the webservice, and build it to a different
assembly that can be distributed to your client.
If you prefare there is an even simpler way. You can use the include
attribute to include the trainingDocument type in the webservice. This way
users can use the wsdl tool of microsoft (either manually or by using web
reference) to create the trainingDocument class and use it in the web service.


Guy, thanks, that's really helpful.

Let me check I've understood this correctly - if I add the
trainingDocument class to the web service, users of the service can
use it to create trainingDocument objects that they can then pass to
the [Webmethod] doing the work. They will be able to do this by adding
a web reference within the client.

Could you give me some more information on this, please?
Say, I have the following:

[WebMethod]
public int AttributeAuthorship ( TrainingDocument [] authorA,
TrainingDocument [] authorB, TrainingDocument anonDoc )
{
// Code to attribute authorship

return authorID;
}
And I have a separate class as a TrainingDocument.cs file:
public class TrainingDocument
{
Attributes...

public TrainingDocument()
{
// Constructor code
}

further methods...
}
How do I add the TrainingDocument class to the web service so that
users can create objects from the class when creating the client?

Matt

Apr 11 '06 #4
Thanks, Guy. I'll give that a go.

Matt

On Tue, 11 Apr 2006 06:30:02 -0700, guybar
<gu****@discussions.microsoft.com> wrote:
Hi Matt,

All you need to do is add the include attribute to the webservice
decleration, as follows:

[WebMethod]
[XmlInclude(typeof(TrainingDocument))]
public int AttributeAuthorship ( TrainingDocument [] authorA,
TrainingDocument [] authorB, TrainingDocument anonDoc )
{
// Code to attribute authorship

return authorID;
}


Apr 11 '06 #5
> >[WebMethod]
[XmlInclude(typeof(TrainingDocument))]
public int AttributeAuthorship ( TrainingDocument [] authorA,
TrainingDocument [] authorB, TrainingDocument anonDoc )
{
// Code to attribute authorship

return authorID;
}


Have u specified how to serialize the TrainingDocument class? Does your
TrainingDocument class look similar to this?

class TrainingDocument
{
string docname;

[XmlElement(ElementName = "docname")]
public string DocName
{
get { return docname; }
set { docname = value; }
}
}

I added the XmlInclude attribute to the webservice method to which im
passing my object as a parameter. But still i get the error that says, "There
was an error generating the XML document." Drilling deeper into the
exception, i get, "The type Space.YourStar was not expected. Use the
XmlInclude or SoapInclude attribute to specify types that are not known
statically."

I'm calling a method called "getIntFromStar(YourStar star)" from a windows
application, to which im passing YourStar object as a parameter. All proper
references are added, including web reference to call the web service method.
The YourStar class looks like this.

class YourStar
{
int starNum;

[XmlElement(ElementName = "starnumber")]
public int StarNumber
{
get { return starNum; }
set { starNumber = value; }
}
}

Plz help. Thanks!
Apr 20 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Shazad | last post: by
5 posts views Thread by vinoth | last post: by
reply views Thread by leslie_tighe | last post: by
4 posts views Thread by leslie_tighe | last post: by
2 posts views Thread by Tim Reynolds | last post: by
3 posts views Thread by =?Utf-8?B?UGllcnJl?= | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.