I'm new to web services. I'm writing a basic file maintenance
application in asp.net. For example I'll fill a grid with all the records
from a table, then allow the user to select a record (row) and I'll show the
individual fields of the row in the form. The user can update the fields and
then I'd like to send the fields back through a web service for updating.
I've tried to specify a custom class as the parameter. See the example
below. My problem is that when I specify the class as a paramenterin the
client application I get a compile time error "Value of type
"IdealClass.atyMaint' cannot be converted to
'Ideal.updAccountType.atymaint." Atymaint is the name of my class. I have
this class defined in a project that is separate from my web service project
and my client project. I then reference this class from both the web service
and client projects. See the excerpts below.
From IdealClass project in atyMaint.vb
Public Class atyMaint
Public AMTYP as string
Public AMDESC as string
Public AMPRICE as string
End Class
From client project
dim atymaint as new idealclass.atymaint
atymaint.amtyp = me.txttype.text
atymaint.amdesc = me.txtdesc.text
atymaint.amprice = me.txtprice.text
dimWebservice as new updAccountType.updAccountType
errMsgString = Webservice.updAccountType(atymaint)
From web service project
<WebMethod () > _
Pubic Function updAccountType(ByVal atymaint as IdealClass.atyMaint) as
string
... stuff
End FunctionHiya! :)
I hope I can provide some help for you, but I'm not quite sure of all the
details as I have forgotten all about VB since C# arrived. ;) Anyway, here's
some hints that might get it working..
When using a web reference you have to use the generated proxy class
'Ideal.updAccountType.atymaint' instead of 'IdealClass.atyMaint'. If you
want to do some plumbing, (and repetitive work :P) you can fix this by
clicking "Show all files" in the Solution Explorer, navigate to your web
reference, expand it and it's Reference.map document. Inside you should find
Reference.vb. Comment out the proxy class, and replace all references to
atyMaint with IdealClass.atyMaint. You have to redo this every time you
update the web reference. In addition, you have to specify how
IdealClass.atyMaint should serialize as XML. Add
<System.Xml.Serialization.XmlRoot("atyMaint")> above Public Class atyMaint,
and <System.Xml.Serialization.XmlElement("AMTYP")> above Public AMTYP as
string etc.
There's a nice tool for generating web service proxy classes called wsdl.exe
included in the .net framework you can use to get rid of the update web
reference problem though. You can read more about it here:
http://msdn.microsoft.com/library/d...erviceProxy.asp
There's also a lot more info on web services in the same folder as that
article. ;)
HTH,
Lars-Erik
"benthanger@.online.nospam"
<benthangeronlinenospam@.discussions.microsoft.com> wrote in message
news:8DEFC42E-21E7-4057-B20B-381B319CB478@.microsoft.com...
> Hi there,
> I'm new to web services. I'm writing a basic file maintenance
> application in asp.net. For example I'll fill a grid with all the records
> from a table, then allow the user to select a record (row) and I'll show
> the
> individual fields of the row in the form. The user can update the fields
> and
> then I'd like to send the fields back through a web service for updating.
> I've tried to specify a custom class as the parameter. See the example
> below. My problem is that when I specify the class as a paramenterin the
> client application I get a compile time error "Value of type
> "IdealClass.atyMaint' cannot be converted to
> 'Ideal.updAccountType.atymaint." Atymaint is the name of my class. I
> have
> this class defined in a project that is separate from my web service
> project
> and my client project. I then reference this class from both the web
> service
> and client projects. See the excerpts below.
> From IdealClass project in atyMaint.vb
> Public Class atyMaint
> Public AMTYP as string
> Public AMDESC as string
> Public AMPRICE as string
> End Class
> From client project
> dim atymaint as new idealclass.atymaint
> atymaint.amtyp = me.txttype.text
> atymaint.amdesc = me.txtdesc.text
> atymaint.amprice = me.txtprice.text
> dimWebservice as new updAccountType.updAccountType
> errMsgString = Webservice.updAccountType(atymaint)
> From web service project
> <WebMethod () > _
> Pubic Function updAccountType(ByVal atymaint as IdealClass.atyMaint) as
> string
> ... stuff
> End Function
0 comments:
Post a Comment