ASMX web service shared between projects - c#

I have an ASMX web service which is being called using Soap protocol. The service is using request / response types from one of our shared projects.
The project that consumes this service is also using the shared project. Now, I want that the reference that's been used in the project for that service should reuse the types being used in the shared project.
If that is not possible then can we inherit the service from an interface and then the wsdl tool can generate the implementation of the interface by inheriting from required classes?
Will WCF be an alternative?

Related

WCF Service : how can I use shared classes?

I have an ASP.NET project that exposes multiple WCF Services.
Most these services make use of common custom classes in the APP_Code folder used throughout the project.
Consuming these WCF services is a console app I have written.
My question is :-
In the console app I obviously instantiate each of the WCF services I'm using - but some of these services utilise the common classes as parameters to some of the methods.
However on the client side (console app) - those classes are exposed exclusively as part of that WCF Service's namespace and not interchangeable)
Example of syntax error is something like :-
cannot convert from 'ManagementAgent.Computer_ServiceReference.ComputerIdentity' to 'ManagementAgent.WorkloadAnalysis_ServiceReference.ComputerIdentity'.
The class "ComputerIdentity" is a commonly shared class in the App_Code folder.
How do I get this class interchangeable as a parameter across multiple WCF Services?
Your shared classes need to come from the same assembly, not just shared code. Put the classes you want to share into their own class library and reference that in all projects.

Expose interface from an ASMX web service

I'm working on an old project that has ASMX web services. The consumer client uses this web service as a web reference. This all works fine except that the web service doesn't expose any interfaces, only concrete classes.
I added an interface to one of the asmx web services, but it seems like that the interface isn't available when I update my web reference on the client app.
Is it even possible to expose an interface from ASMX web services?

How to use proxy class generated by WSDL in web service?

Disclaimer: My experience/knowledge of web services is very limited.
There is an existing web service WSDL that I have reverse engineered with wsdl.exe to create a C# proxy class.
Using Visual Studio 2008 I created a default web service template.
How do I reference the generated proxy class so that it will work in the web service?
For example -> calling http://localhost/webservice/service.asmx?WSDL will return the details from the proxy class.
First of all, you should not be using ASMX web services. Microsoft now considers them to be "legacy technology", and suggests that all new development of web service clients or services be done using WCF. Don't start off at a disadvantage.
Secondly, the normal way to make use of a WSDL is to use the "Add Web Reference" command in Visual Studio ("Add Service Reference" if you were using WCF). This generates the proxy classes for you and adds them to your project.
I'm not sure from your question that this is what you want, since you first talk about the WSDL, but then talk about a "default web service template". What do you mean to do with the "default web service template"?
Try using the svcutil.exe program (not WSDL.EXE) as follows:
svcutil YourWsdl.WSDL /language:C# /d:subdirectory
This should produce a number of files in the subdirectory. Take a look at the .cs files, one of which will contain an interface which is the service contract. That is the interface that your service must implement. Look at your "default" WCF service application and you'll see that it does the same thing - produces an interface that is implemented by the service.

sharing interfaces with web services in .net

I am using a web service. I define an interface in the web service.
Can I use this interface definition in my project that invokes the web service? I know I can use classes defined in the web service.
Do I have to do anything special with the interface like add an attribute?
Before you generate the service client add a reference to the assembly containing the interfaces and enable the option "Reuse types in referenced assemblies" in the client generation interface. It should use the already existing types instead of generating new ones.

Can I generate proxy objects for WCF service library using scriptmanager?

I have used the AJAX Enabled WCF Service template from within a web application. By adding a Service reference to the scriptmanager, some client objects are generated allowing me to easily consume the service. My question is can I do anything like that when I use a WCF Service Library? I added the project to my solution and in my web app I added a service reference to the service. This is where I get a bit stuck. What do I do now to allow consuming the service from the client.
So, just to consume wcf service, you have to use "svcutil" app from VS pack to generate o proxy class, which is very simple in usage.

Categories