Currently Being Moderated

In our last project we had several problems in calling BODS webservice via the Java Webdynpro. The import of the model to the NWDS was not successful. Also creating a CAF service around the BODS webservice didn't lead to the expected result. So we decided to implement the the BODS call via the BODS API.

The first step was to create configurations in the NWA. This enabled us to switch the target BODS system in a configuration and not in the code. Next was to create the RTService call and add for example the input string.

After that the RTService was executed. Then we parsed the result, did some error handling and passed back our result.

Down below you can find some code snippets

import com.businessobjects.rtsclient.RTServiceClientX;

import com.businessobjects.rtsclient.RTServiceException;

RTServiceClientX rts = new RTServiceClientX();
        try {
            //generate input for RTServiceClient

 

        String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " + "<IBANInformation> "
                + "<MDM_BANK_NUMBER>"+bankNumber+"</MDM_BANK_NUMBER> "
                + "<MDM_BANK_ACCOUNT_NUMBER>"+bankAccountNumber+"</MDM_BANK_ACCOUNT_NUMBER> "
                + "<MDM_BANK_CONTROL_KEY>"+bankControlKey+"</MDM_BANK_CONTROL_KEY> "
                + "<MDM_SWIFT_CODE>"+swiftCode+"</MDM_SWIFT_CODE> "
                + "<MDM_COUNTRY>"+country+"</MDM_COUNTRY>"
                + "</IBANInformation>";

             //get configuration data
            IWDWebModule module = wdComponentAPI.getDeployableObjectPart().getWebModule();
            IWDConfiguration config = WDConfiguration.getConfiguration(module);

            //execute call to RTServiceClient
            String bodsResult = "";
            rts.connect(config.getStringEntry("BODS_SYSTEM"), config.getIntEntry("BODS_PORT"));
            try {
                bodsResult = rts.invoke("IBANGeneration", input);
            } catch (RTServiceException e) {
                GUId logid = logger.traceThrowableT(Severity.ERROR, "", e).getId();
                wdComponentAPI.getMessageManager().reportMessage(IMessageIBANComp.ERROR, new String[] { logid.toString() });
            }
            rts.disconnect();

            //parse result of call to RTServiceClient
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            InputStream is = new ByteArrayInputStream(bodsResult.getBytes("UTF-8"));
            Document doc = db.parse(is);
            doc.getDocumentElement().normalize();
            NodeList nodeList = doc.getElementsByTagName("IBAN");
            if (nodeList.getLength() > 0) {
                String iban =nodeList.item(0).getTextContent();
                if (iban.equals("0")){//return if error
                    NodeList errorCodeList = doc.getElementsByTagName("ERRORCODE");
                    NodeList errorMessageList = doc.getElementsByTagName("ERRORMESSAGE");
                    // If error code is 201 just go back. No real error
                    if(errorCodeList.item(0).getTextContent().equalsIgnoreCase("201"))
                        return null;
                    wdComponentAPI.getMessageManager().reportException("Error during call to BODS RTServiceClientX: Errorcode:" +
                     errorCodeList.item(0).getTextContent()+" Error Message:"+errorMessageList.item(0).getTextContent());
                    throw new Exception("Error during call to BODS RTServiceClientX: Errorcode:" + errorCodeList.item(0).getTextContent()+
                     " ErrorMessage:"+errorMessageList.item(0).getTextContent());    
                              }else{
                    return iban;
                }
            }
        } catch (Exception e) {

 

        }

Comments

Actions

Filter Blog

By author: By date:
By tag: