CA Service Management

 View Only
  • 1.  SOAP ERROR policy limit exceeded

    Posted Jul 01, 2020 05:07 PM

    Hi,

    I am trying to add an attachment in the request via web service call createAttachement but when i try to run the SOAP request,it give me an error "policy limit exceeded".

    I  have modified the NX_ROOT\samples\sdk\websvc\java\test3_attachments\create_attachment.java file. but still not working.  i have added the following:

    FileDataSource fds = new FileDataSource(filename); DataHandler dhandler = new DataHandler(fds); CA SDM._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME); CA SDM.addAttachment(dhandler); String handle = CA SDM.createAttachment(sid, repHandle, objHandle, description, filename);



    ///////////////////////////////////////////////////////////////////////////////
    //         Copyright (c) 2008 CA.
    // as an unpublished work. This notice does not imply unrestricted or public
    // access to these materials which are a trade secret of CA
    // or its subsidiaries or affiliates (together referred to as
    // CA), and which may not be reproduced, used, sold or
    // transferred to any third party without CA's prior written consent.
    //
    //                         All Rights Reserved.
    //
    //                       RESTRICTED RIGHTS LEGEND
    // Use, duplication, or disclosure by the Government is subject to
    // restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
    // Technical Data and Computer Software clause at DFARS 252.227-7013.
    ///////////////////////////////////////////////////////////////////////////////
    // Module:  Service Desk Web Services example
    // Created: 08/06/08
    ///////////////////////////////////////////////////////////////////////////////
    //
    //		README!  README!  README!  README!  README!  README!
    //
    // Description:
    //	This class file contains examples of invoking the R12 CA Service Desk Web Services.
    //
    //	THIS SHOULD BE RUN IN A TEST ENVIRONMENT AGAINST A TEST SERVICE DESK SERVER!
    //	The routines in this file will create and modify Service Desk objects!
    //
    //	create_attachment.java demonstrates the login(), getHandleForUserid(),
    //	createRequest(), createAttachment() and logout() methods. It attaches the file
    //	test_upload_file.txt to the request.
    //
    // Instructions to build and run this program:
    //
    //	Copy the run_java_test_bat.txt (Windows) or run_java_test_sh.txt (Unix) from 
    //	NX_ROOT/samples/sdk/websvc/java.  Edit the file so that it sets the variables
    //	to correct values.  TEST_APP should be set to create_atachment.  
    //	The other variables must be set to find the java and javac executables and
    //	the JAR files that go into the classpath.  These scripts will 
    //	run WSDL2Java to create the CA Service Desk Web Services client-side stub 
    //	files, compile these, then compile and run the test program.
    //
    //	Note that the JRE installed on some platforms does not include javac.  In these
    //	cases you will need to obtain the JDK for your platform to build and run these
    //	tests.
    //
    //	In the test program, verify that username, password and endpoint are correct
    //	for your installation of CA Service Desk.
    //
    //	Rename run_java_test_bat.txt to run_java_test.bat or run_java_test_sh.txt to 
    //	run_java_test.sh and run the script from the current directory.
    //
    ///////////////////////////////////////////////////////////////////////////////
    
    import javax.xml.rpc.holders.StringHolder;
    import javax.activation.DataHandler;
    import javax.activation.FileDataSource;
    
    import org.apache.axis.client.Call;
    import org.apache.axis.AxisFault;
    
    // Import the CA Service Desk client-side stubs.
    import com.ca.www.UnicenterServicePlus.ServiceDesk.*;
    
    public class create_attachment 
    {
      
        public create_attachment()
        {
            // The endpoint, username and password may need modification to match
    	// the installation of CA Service Desk.
            String endpoint = "http://localhost:8080/axis/services/USD_R11_WebService";
            String username = "ServiceDesk";
    	String password = "ServiceDesk";
    
    	// The file to upload to a Request.
            String filename = "./test_upload_file.txt";
    
    	// The out of box Service Desk repository has handle: "doc_rep:1002".
    	String ServiceDeskDocumentRepository = "doc_rep:1002";
          
            try
            {
                // create a new web service stub instance
                USD_WebServiceLocator ws = new USD_WebServiceLocator();
                java.net.URL url = new java.net.URL(endpoint);
                USD_WebServiceSoap usd = ws.getUSD_WebServiceSoap(url);
    
    	    // login()
                int sid = usd.login(username, password);
                System.out.println("\nSID: " + sid);
    
    	    // getHandleForUserid()
                String custHandle = usd.getHandleForUserid(sid, username);
                System.out.println("Handle for '" + username + "' is: " + custHandle);
    	
                // createRequest()
                ArrayOfString attrVal = new ArrayOfString();
                attrVal.setString(new String[]{
                                       "customer", custHandle, 
                                       "description", "Request created for a createAttachment() test"});
                ArrayOfString attr = new ArrayOfString();
                attr.setString(new String[0]);
                ArrayOfString prop = new ArrayOfString();
                prop.setString(new String[0]);
    
                StringHolder newRequestHandle = new StringHolder();
                StringHolder newRequestNumber = new StringHolder();
    
                String result;
                result = usd.createRequest(sid, "", attrVal, prop, "", attr, newRequestHandle, newRequestNumber);
                System.out.println("Created Request: " + newRequestNumber.value + ", Handle: " + newRequestHandle.value);
    
                // Setup the client soap request
    			FileDataSource fds = new FileDataSource(filename);
    			DataHandler dhandler = new DataHandler(fds);
    			CA SDM._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT,Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);
    			CA SDM.addAttachment(dhandler);
    
    			String handle = CA SDM.createAttachment(sid, repHandle, objHandle,description, filename);
               
    	    // createAttachment()
                String attmntHandle = usd.createAttachment(sid, ServiceDeskDocumentRepository, newRequestHandle.value, "createAttachment test file", filename);
                if (attmntHandle.length() > 0)
                    System.out.println("\nSuccessfully uploaded the file to the Request, attachment handle: " + attmntHandle + "\n");
    
    	    usd.logout(sid);
               
            }
            catch (AxisFault af)
            {               
                System.out.println("...AxisFault...");
                System.out.println(af.toString());
            }    
            catch(Exception e)
            {
                e.printStackTrace();
            }
           
        }
     
        static public void main(String[] argv)
        {
            new create_attachment();
        }
     
    }
    


    How it can be resolved?

    Thanks,



  • 2.  RE: SOAP ERROR policy limit exceeded

    Posted Jul 02, 2020 02:03 AM
    You'll need to increase ILIMIT in the NX.env . I don't have access to a reference implementation right now and I don't remember the variable name by heart. The only one I found with a quick googling is mentioned on https://knowledge.broadcom.com/external/article/52680/after-nxsurveyilimit-is-set-in-nxenv-the.html but it mentions surveys and I don't remember if that is global or if there is another setting for the ilimit for non-survey stuff. Someone else who knows what I'm talking about maybe pitch in?  @Mugur Anghel @Razvan Dragoi​​?


  • 3.  RE: SOAP ERROR policy limit exceeded
    Best Answer

    Posted Jul 02, 2020 07:07 AM
    This error also may happen if the upload doesn't succeed.
    I see that you use the DIME encapsulation format. Bad idea, even if it is documented. The sample code is bad also, and has never been fixed.
    Painful past experience proves that the DIME encapsulation breaks when the file size is over a few megs.
    Use Call.ATTACHMENT_ENCAPSULATION_FORMAT_MIME instead, and you should be fine.


  • 4.  RE: SOAP ERROR policy limit exceeded

    Posted Jul 02, 2020 12:15 PM
    Hi Jean-Pierre, thans for your answer. When you say use MIME encapsulation format you mean just change "Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME" and use Call.ATTACHMENT_ENCAPSULATION_FORMAT_MIME in the code?


  • 5.  RE: SOAP ERROR policy limit exceeded

    Posted Jul 03, 2020 05:58 AM
    Exactly