Hi,
I'm new to web services and I'm having some trouble figuring out how to
define a custom object that works through the webservice.
For example, I have the following on the server side:
public class Token
{
private string firstID;
private string secondID;
public string getFirstD() { return firstID; }
public string getSecondID() { return secondID; }
public void setFirstID(string id) { firstID= id; }
public void setSecondID(string id) { secondID= id; }
}
[WebMethod]
public bool GetResellerList2(Token token, string languageisocode)
{
return true;
}
When I view the object on the client side, I can't see any of the properties
or methods defined in the Token class. What am I missing?
Thanks,
Chris
Nassos - 22 Jun 2005 13:16 GMT
Hi Chris,
if inside the asmx file of the ws do not use the custom class it did not
publish it. to check if it is published go to the web reference of the
project that you reference the ws and press "show all files"
expand the reference of the ws and expand the Reference.map in there it is a
Reference.cs open it, if your custom class is not in there
/// <remarks/>Web Service Class
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="LiveUpdateSoap",
Namespace="http://orama-tech.gr/WebServices/")]
public class LiveUpdate :
System.Web.Services.Protocols.SoapHttpClientProtocol {
}
/// <remarks/>
///Custom class
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://localhost/WebServices/")]
public class DownloadInfo {
}
as the ws class
then you can do anything with it. You can add in the Reference.cs
programmably.
Hope that Helps.
> Hi,
>
[quoted text clipped - 37 lines]
>
> Chris
Nassos - 22 Jun 2005 13:22 GMT
So put in the Reference.cs the following:
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://orama-tech.gr/WebServices/")]
public class Token
{
private string firstID;
private string secondID;
public string getFirstD() ;
public string getSecondID() ;
public void setFirstID(string id) ;
public void setSecondID(string id) ;
}
> Hi,
>
[quoted text clipped - 37 lines]
>
> Chris
Chris - 24 Jun 2005 18:55 GMT
Hmm ... I see what you mean, but if I add this class to References.cs, it's
added on the client side. Everytime I update the web reference, the changes
that were made would disappear. Is there any way to ensure that the methods
get published on the server side?
Chris
> So put in the Reference.cs the following:
> /// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://orama-tech.gr/W
ebServices/")]
> public class Token
> {
[quoted text clipped - 52 lines]
> >
> > Chris
Marvin Smit - 23 Jun 2005 11:16 GMT
Hi,
ehhh... Web Services expose the public properties and WebMethod
annotated functions.
Since you use "Token" as a parameter, and the "Token" class only
contains private properties (don't get serialized) and public methods!
nothing of this class will be available in the WebService call.
if you change you data-class as follows
public class Token
{
private string firstID;
private string lastID;
public string FirstID
{
get
{
return firstID;
}
set
{
firstID = value;
}
}
public string LastID
{
get
{
return lastID;
}
set
{
lastID = value;
}
}
}
and use that in your WebService you'll see the availability of
"FirstID" and "LastID" within the generated proxy of this service on
the client side.
Hope this helps,
Marvin Smit
>Hi,
>
[quoted text clipped - 36 lines]
>
>Chris
Chris - 24 Jun 2005 18:43 GMT
Hmm ... what if I wanted the actual method calls rather than property
getters? I'm currently mocking out a temporary .net webservice.
Unfortunately, when it makes it into production, it will be a Java based
webservice where we'll be doing method calls on custom objects provided by
the webservice. I just want to mimic the same functionality here and I
don't think properties are going to work ... is there another solution?
Thanks,
Chris
> Hi,
>
[quoted text clipped - 88 lines]
> >
> >Chris