Originally posted on:
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_21355401.html
I have a solution containing two projects: a webservice project and a web app project which has a web reference to the webservice project (the web app project is simply a test case).
My webservice project includes a class file containing multiple public structs. I can use these just fine from within the webservice project itself. However, I’m not able to see or reference the structs from within the web app project.
Isn’t it true that when you add a web reference to a web service, you essentially get an “object” version of the webservice? In that case I expect to be able to access any public members of the webservice.
I have previously created services that reference associated projects, and when I consume the service, I have access to the referenced projects and their members. Why don’t I have access to a class file that’s in the same project as the service?
The Namespace for the webservice (asmx) and the class file (cs) are the same. In the web app, I have a using statement for the web reference. I DO have access to the webmethods from the asmx, just not the associated class files and their public members…
I’m having the same problem, someone could tell me what’s the solution?
I would like to send a list of parameter struct publicly available on the WebService.
First of all, you should be using WCF instead of ASMX web services for all new development.
Second, when you add a Web Reference (or, preferably a Service Reference), you get proxy copies of all the types exposed by the web service. If the service returns a class that contains a public property of some struct type, then you will get a proxy copy of the returned class, as well as a proxy copy of the struct type.
You’ll get a class, BTW, not a struct. The concept of “struct” doesn’t translate across service boundaries.