Answered by:
Web Service Structure

Question
-
User1953081067 posted
Hi
I'm very new to web services. After a little YouTube research, I've built and run my first basic web service.
What I'd like to understand is how best to structure it. For example: One ASMX file contains one class with multiple methods. I've worked out I need 8 or so classes (each with a number of methods), which means I need to create 8 ASMX files, and then references all 8 to my website that uses them.
Is there not a way I can use only one ASMX file and create multiple classes - like I would in a cs file with namespacese? It just seems long winded to add a reference for every file I create.
Thanks as always
Monday, January 21, 2013 10:54 AM
Answers
-
User-1000095884 posted
Hi,
You can have single service with multiple contracts, but you need to have a class that implement all of the service contracts that you have exposed and configure the service like.
<service name="ServiceNameSpace.ServiceImplementationCLass" behaviorConfiguration="ServiceBehavior"> <endpoint address="" binding="basicHttpBinding" contract="ServiceContract1" /> <endpoint address="" binding="basicHttpBinding" contract="ServiceContract2" /> </service>
Best Regards.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, January 23, 2013 1:31 AM
All replies
-
User622904130 posted
i would created 1 asmx, then create the function that call the distinct functions in your classes.
Monday, January 21, 2013 12:16 PM -
User1953081067 posted
Hummmm. Is there any easy way to include 8 or so web services to a website without addeding references for all of them?
Thanks
Monday, January 21, 2013 4:46 PM -
User-1000095884 posted
Hi,
You can have single service with multiple contracts, but you need to have a class that implement all of the service contracts that you have exposed and configure the service like.
<service name="ServiceNameSpace.ServiceImplementationCLass" behaviorConfiguration="ServiceBehavior"> <endpoint address="" binding="basicHttpBinding" contract="ServiceContract1" /> <endpoint address="" binding="basicHttpBinding" contract="ServiceContract2" /> </service>
Best Regards.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, January 23, 2013 1:31 AM