Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Issue while Calling Rights Management LifeCycle Server web service to apply policies to a pdf

Avatar

Level 1

Hi,

I am trying to apply a policy to a pdf using MTOM LifeCycle server web service API. Currently the server is using the https protocol. I followed the below links for this.

Adobe LiveCycle * Applying Policies to PDF Documents

Adobe LiveCycle * Quick Start (MTOM): Applying a policy to a PDF document using the web service API

I changed the IP address in the URL while adding the reference and creating the endpoint. But I am receiving the below error message.

The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via.

can someone please help.

Thanks,

Nikhil

2 Replies

Avatar

Level 1

Below is the c# code and config files.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.ServiceModel;

using System.IO;

using System.Net;

using System.Net.Security;

using System.Security.Cryptography.X509Certificates;

using ConsoleApplication1.ServiceReference1;

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            try

            {

                //Create a RightsManagementServiceClient object

                RightsManagementServiceClient rmClient = new RightsManagementServiceClient();

                rmClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://IPAddressofSite/soap/services/RightsManagementService?blob=mtom");

               //Enable BASIC HTTP authentication

                BasicHttpBinding b = (BasicHttpBinding)rmClient.Endpoint.Binding;

                b.MessageEncoding = WSMessageEncoding.Mtom;

                rmClient.ClientCredentials.UserName.UserName = "********";

                rmClient.ClientCredentials.UserName.Password = "*********";

                b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                //b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

               b.Security.Mode = BasicHttpSecurityMode.Transport;

              

             

                //Create a BLOB that represents the PDF document

                //to which a policy is applied

                BLOB inDoc = new BLOB();

                //Reference the PDF document to which a policy is applied

                string inputFileName = @"P:\PDF\TextToPDf.pdf";

                FileStream fs = new FileStream(inputFileName, FileMode.Open);

                //Get the length of the file stream

                int len = (int)fs.Length;

                byte[] ByteArray = new byte[len];

                //Populate the byte array with the contents of the FileStream object

                fs.Read(ByteArray, 0, len);

                inDoc.MTOM = ByteArray;

                //Prepare output parameters

                string PolicyID;

                string DocumentID;

                string MimeType;

                SetCertificatePolicy();

                //Apply a policy to a PDF document named Loan.pdf

                BLOB outDoc = rmClient.protectDocument(

                    inDoc,

                    "TextToPDf.pdf",

                    "Test Policy Set",

                    "Test Policy 1",

                    null,

                    null,

                    ConsoleApplication1.ServiceReference1.RMLocale.en,

                    out PolicyID,

                    out DocumentID,

                    out MimeType);

                //Populate a byte array with the contents of the BLOB

                byte[] outByteArray = outDoc.MTOM;

                //Create a new file containing the policy-protected PDF document

                string FILE_NAME = @"P:\PDF\PolicyProtectedLoanDoc.pdf";

                FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate);

                BinaryWriter w = new BinaryWriter(fs2);

                w.Write(outByteArray);

                w.Close();

                fs2.Close();

            }

            catch (Exception ee)

            {

                Console.WriteLine(ee.Message);

                Console.ReadKey();

            }

        }

        /// <summary>

        /// Sets the cert policy.

        /// </summary>

        public static void SetCertificatePolicy()

        {

            ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;

        }

        /// <summary>

        /// Remotes the certificate validate.

        /// </summary>

        private static bool RemoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)

        {

            // trust any certificate!!!

            System.Console.WriteLine("Warning, trust any certificate");

            return true;

        }

    }

}

web.config:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

    <system.serviceModel>

        <bindings>

            <basicHttpBinding>

                <binding name="RightsManagementServiceSoapBinding" closeTimeout="00:01:00"

                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

                    useDefaultWebProxy="true">

                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                    <security mode="Transport">

                        <transport clientCredentialType="None" proxyCredentialType="None"

                            realm="AXIS" />

                        <message clientCredentialType="UserName" algorithmSuite="Default" />

                    </security>

                </binding>

                <binding name="RightsManagementServiceSoapBinding1" closeTimeout="00:01:00"

                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

                    useDefaultWebProxy="true">

                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                    <security mode="None">

                        <transport clientCredentialType="None" proxyCredentialType="None"

                            realm="" />

                        <message clientCredentialType="UserName" algorithmSuite="Default" />

                    </security>

                </binding>

            </basicHttpBinding>

        </bindings>

        <client>

            <endpoint address="https://IPAddressofSite/soap/services/RightsManagementService"

                binding="basicHttpBinding" bindingConfiguration="RightsManagementServiceSoapBinding"

                contract="ServiceReference1.RightsManagementService" name="RightsManagementService" />

        </client>

    </system.serviceModel>

</configuration>

Avatar

Level 1

Hi,

I am managed to resolve the above error by adding the line(in RED) above. But now I am getting a new error message below.

Caused by: java.lang.NoClassDefFoundError: com/adobe/livecycle/rightsmanagement/helper/RMServiceEJBHelper; nested exception is: java.lang.NoClassDefFoundError: com/adobe/livecycle/rightsmanagement/helper/RMServiceEJBHelper


Can you please help me with this at your earliest.


Thanks,

Nikhil