Working with SOAP API

Ingeniux CMS Web Services API

Below is a step by step example on how to work with Ingeniux CMS Web Services API, via SOAP connection. We are using the most common way to consume a SOAP service, which is to add a SOAP service as a "Service Reference" in your Visual Studio Project:

Please note we are working with Visual Studio 2012 or later.

Adding the Service References to Ingeniux CMS Web Services API

  1. Bring up the right click Content Menu on the Visual Studio Project we are using to integrate with Ingeniux CMS Web Services API.

    addserviceref-menu
  2. Add "MembershipProvidersServices.svc" reference first. It is needed to perform authentication again the Ingeniux CMS Web Services API.

    Please note that the address of SOAP Service is always [your site address]/SOAP/[service name].svc.

    addserviceref
  3. Add the service you need to work with as reference. In this case, it is the "SiteTreeServices.svc".

    addsitetreesvr
Write the code to work with Ingeniux CMS Web Services API

Preparation

  1. Make sure the following namespaces are used:

    C#
    using YourNameSpace.MembershipService;
    using YourNameSpace.SiteTreeServices;
  2. Create the binding object. Ingeniux CMS SOAP API uses WSHTTPBinding in compliance to SOAP 1.2:

    C#
    //token based authentication means the binding itself doesn't need to use any security mode
    WSHttpBinding httpBinding = new WSHttpBinding(SecurityMode.None);
    
    httpBinding.CloseTimeout = new TimeSpan(0, 1, 0);
    httpBinding.OpenTimeout = new TimeSpan(0, 1, 0);
    httpBinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
    httpBinding.SendTimeout = new TimeSpan(0, 10, 0);
    httpBinding.AllowCookies = true;

Authenticate again Ingeniux CMS SOAP API

  1. Create the EndPoint to the membership providers services:

    C#
    EndpointAddress endpoint = new EndpointAddress("http://[your site name]/soap/MembershipProvidersServices.svc");
  2. Create an instance of "MembershipProvidersServicesClient", using the prepared binding object and endpoint above.

    Call the "Login" method on the service client instance to retrieve the security token.

    In this case, we are storing it as a variable. You could keep the token around as static field, or as cache or session data for web applications.

    C#
    string token = String.Empty;
    using (MembershipProvidersServicesClient mservice = new MembershipProvidersServicesClient(httpBinding, endpoint))
    {
        //membership provider name is listed under local-membership.config
        token = mservice.Login("[user name]", "[password]", "[Membership Provider Name]").message;
    }

Calling the SiteTreeServices with retrieved security token

  1. Create the endpoint to the SiteTreeServices address:

    C#
    endpoint = new EndpointAddress("http://[your site address]/soap/SiteTreeServices.svc");
  2. Create the SiteTreeServicesClient instance, open a OperationContextScope, set the security token to the soap header, and call the site tree services' "GetChildPages" function:

    C#
    using (SiteTreeServicesClient service = new SiteTreeServicesClient(httpBinding, endpoint))
    {
        using (OperationContextScope scope = new OperationContextScope(service.InnerChannel))
        {
            //set security token, without it the service to reject the call and return "not authenticated" error
            OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("IGXAToken", "IGXNameSpace", token));
    
            //now we can call the service, to the child pages information, for folder "x2", under pub target "PublishingTargets/225"
            var res = service.GetChildPages(
                                    new TreeNodeInfo
                                    {
                                        objectId = "x2",
                                        widgetId = "x2",
                                        index = 0
                                    },
                                    "PublishingTargets/225",
                                    0);
    
            //actual information is always the "message" property of return object
            PageNodeInformation[] childrenInfo = res.message;
        }
    }
See Also

Other Resources