Passing Objects Via Web Service
I have a simple question about passing custom objects via a webservice.
I created a class library called UserLibrary, compiled it and created a dll for it.
Then I created a web service in another project and referenced this dll.
Now I am passing in and retur开发者_运维知识库ning an object from the dll in my WebMethod
When I consume the WebMethod in the client, in order to pass these custom objects to the service, I have to add a reference to the dll in the client and it works fine.
Question is what if the client didnt have access to the dll, then the web service couldn't be used? Should we be passing and returning custom objects in our WebMethods or is it a better idea to simply return and pass simple objects like strings instead?
You don't need to reference the .dll with object types your service consumes. Instead, when you add a service reference to your project in Visual Studio, all the necessary types will be generated for you based on service's meta data.
精彩评论