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.
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.
RichardLaw
Member
464 Points
626 Posts
Web Service Structure
Jan 21, 2013 02:54 PM|LINK
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
UstesG
Contributor
2098 Points
449 Posts
Re: Web Service Structure
Jan 21, 2013 04:16 PM|LINK
i would created 1 asmx, then create the function that call the distinct functions in your classes.
But don't expect me to do your job!
RichardLaw
Member
464 Points
626 Posts
Re: Web Service Structure
Jan 21, 2013 08:46 PM|LINK
Hummmm. Is there any easy way to include 8 or so web services to a website without addeding references for all of them?
Thanks
Haixia Xie -...
Contributor
3030 Points
296 Posts
Microsoft
Re: Web Service Structure
Jan 23, 2013 05:31 AM|LINK
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.
Feedback to us
Develop and promote your apps in Windows Store