![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello group, Somebody has a example where web methods receive and send classes in the parameters. I looking the best way to send parameters to web service and anybody told me something like that. Thanks a lot for help, leon |
#3
| |||
| |||
|
|
I looking the best way to send parameters to web service and anybody told me something like that. |
#4
| |||
| |||
|
|
You're not supposed use "classes" as arguments to web service operations, but use XML data that will be deserialized as a class in a language of choice. |
|
A web service operation is meant to specify (if any) data structures as arguments. A data structure will be, in serialized form, XML data. Languages like .NET allow you to use classes or structs to represent those data structures which will be serialized/deserialized by the language itself. |
#5
| |||
| |||
|
|
Parameters can be Primatives, Objects (serialized object), XMLNode, or a raw XML (String). |
#6
| |||
| |||
|
|
"leon" <faleusqui (AT) hotmail (DOT) com> wrote in news:uZNl07gOIHA.4688 (AT) TK2MSFTNGP06 (DOT) phx.gbl: I looking the best way to send parameters to web service and anybody told me something like that. Yes you can send a serializable class in the parameter of a web service ... However in practice I found this to be a bad idea - Used of the web service seem to prefer discrete parameters. Returning a class (or DTO) is prefectly OK however. -- spamhoneypot (AT) rogers (DOT) com (Do not e-mail) |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
For the upload operation a simple example below: Files are always an array of bytes, so -- byte[]. Your uploads will probably refer the name you want to give the file, so -- string name. [DataContract(Name="UploadInput")] class UploadInput { [DataMember(Name="Data", Order="0")] byte[] data; [DataMember(Name="Name", Order="1")] string name; } [ServiceContract(Name="FileManager")] interface IFileManager { [OperationContract(Name="Upload")] void Upload(WsFileInfo uploadInput) } class ServiceImpl : IFileManager { /* interface implementation */ (...) } -- Going forward, you need to define the kind of input and output you need for each operation. Also, use namespaces that allow you to version the datacontracts, the portTypes (interfaces), the service implementation. As for performance, if there is no instance state involved, opt for InstanceContextMode=InstanceContextMode.Single for best throughput. Opt also for ConcurrencyMode=ConcurrencyMode.Multiple if thread-safe behavior is garanteed. As for exposure, consider netNamedPipeBinding or netTcpBinding to achieve best throughput. basicHttpBinding and wsHttpBinding are also options required when hosting in IIS6. IIS7 will allow you to to explore the other bindings I mentioned while taking advantage of recycling and high availablity as offered by WAS. Ultimately, understand the scenario where this service will be applicable and how its used. It should give you the best understanding of how it should evolve in short term so that the design is flexible enough to handle changes. Hope it helps Tiago Halm |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |