help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

Extending Web Services

 

Introduction

You might want create and use XML WebServices as a part of your application. AxCMS.net makes extensive use of WebServices. Most of them are hosted in the AxCMSPublishService application. We recommend to run your custom WebServices as a part of AxCMSPublishService application. The advantages are:

  • You don't have to manage another configuration file.
  • You don't have to deploy CMS DLLs into another /bin folder.
  • You can reuse WSE infrastructure.

Typical AxCMS.net-solution include an ExtraServices web project, which resides physically under AxCMSPublishService/ExtraServices, thus inheriting all the configuration from the AxCMSPublishService project.

You can develop your WebServices in the ExtraServices project as usual. To configure and run your services consider the following:

  • Put all the configuration needed for your WebServices into the web.config from AxCMSPublishService
  • After each compilation the DLLs are created under AxCMSPublishService/ExtraServices/bin. AxCMSPublishService/ExtraServices is not an independent application, but just a folder and AxCMSPublishService application. Due to this fact, you have to copy all the project output from AxCMSPublishService/ExtraServices/bin to AxCMSPublishService/bin. You can do it manually, but preferably you can extend PostBuild.build script to copy the dlls needed after each compilation.

 

WSE considerations

When you develop your service hosted in AxCMSPublishService, you have to protect your service with the AxCMSWsePolicy. To do so, put the Propery attribute for your service class. Please ensure that Microsoft.Web.Services3-dll is included as reference.

[Policy(typeof(AxCmsWsePolicy))]
public class MyService : System.Web.Services.WebService
{
  ....

Accessing WebServices 

We recommend to reuse the AxCMS.net framework for your service clients (the web service proxy classes). To create such client, please follow the following procedure.

(If you are a AxCMS.net developer, you have to follow it)

  1. Ensure you have WSE 3.0 (full edition including VS 2005 plugin) installed.
  2. Right click on your project, where you want to add a web reference, select 'WSE Settings 3.0' and check the checkbox under gereral tab (Enable this project for Web Services Enhancements).
  3. Use the web reference wizard to add a new web reference to your client project. You'll end up with a Reference.cs file generated by wizard.
  4. Make this file a normal class definition file by moving it directly under the project root and renaming it to YourServiceProxy.cs.
  5. Ensure you have two classes there: YourService and YourServiceWse. If not, go to point 1.
  6. Edit both classes: ensure they have a parameterless and empty constructor; remove the following generated members: useDefaultCredentialsSetExplicitly, Url, UseDefaultCredentials, CancelAsync and IsLocalFileSystemWebService (they are not needed).
  7. Create an interface IYourService containing all operations of your service. Implement this interface in your in step 6 created and modified classes.
  8. Create the following factory method to instantiate a proxy class:
    public static IYourService YourService
    {
    get
    {
    WebServiceGatewayConfiguration configuration =
    (WebServiceGatewayConfiguration)ConfigurationSettings.GetConfig("YourService");
    return (IYourService)configuration.CreateProxy(
    "YourCompany.Namespace1.Namespace2.YourService",
    "YourCompany.Namespace1.Namespace2.YourServiceWse");
    }
    }

    (If you are a AxCMS.net developer, create this member in AxCMSWebApi)
  9. Extend your web.config with following section:
    <section name="YourService" type="Axinom.AECMS.Gateway.GatewayConfiguration, AxCMS.BL" />
  10. Extend your web.config with the following custom section definition:
    <YourService type="WebService">
    <Url>http://localhost/AxCMSPublishService/ExtraServices/YourService.asmx</Url>
    <Timeout>30</Timeout>
    <!-- seconds -->
    <UseWSE>true</UseWSE>
    <Username>Name</Username>
    <Password>Password</Password>
    </YourService>
  11. That's it.
  12.  

11. Don't forget to remove the web reference files generated by the VS 2005 wizard. You don't need them.