cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error General Splitter sequence failed 0

former_member76287
Participant
0 Likes
1,363

Dear Expert,

Need help

i have add general splitter after successfactors and find this error

org.apache.camel.CamelExchangeException: Sequential processing failed for number 0. Exchange[ID-vsa7243618-42121-1579299367455-2616-6]. Caused by: [org.apache.camel.CamelExchangeException - Sequential processing failed for number 1. Exchange[ID-vsa7243618-42121-1579299367455-2616-10]. Caused by: [javax.script.ScriptException - java.lang.Exception: java.lang.NullPointerException: Cannot invoke method getBytes() on null object@ line 30 in script3.groovy]], cause: java.lang.NullPointerException: Cannot invoke method getBytes() on null object

is there any idea what happened is ?here is my design

this is the data that i have from successfactors
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://api10preview.sapsf.com:443/odata/v2/"><title type="text">cust_TransactionWallet2</title><id>https://api10preview.sapsf.com:443/odata/v2/cust_TransactionWallet2</id><updated>2020-01-31T12:51:34Z</updated><link rel="self" title="cust_TransactionWallet2" href="cust_TransactionWallet2"></link><entry><id>https://api10preview.sapsf.com:443/odata/v2/cust_TransactionWallet2(effectiveStartDate=datetime'2020-01-31T00:00:00',externalCode='00115373',transactionSequence=9L)</id><title type="text"></title><updated>2020-01-31T12:51:34Z</updated><author><name></name></author><link rel="edit" title="cust_TransactionWallet2" href="cust_TransactionWallet2(effectiveStartDate=datetime'2020-01-31T00:00:00',externalCode='00115373',transactionSequence=9L)"></link><category term="SFOData.cust_TransactionWallet2" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"></category><content type="application/xml"><m:properties><d:externalCode>00115373</d:externalCode><d:effectiveStartDate m:type="Edm.DateTime">2020-01-31T00:00:00</d:effectiveStartDate><d:transactionSequence m:type="Edm.Int64">9</d:transactionSequence><d:cust_OrderNumber>00115373192</d:cust_OrderNumber><d:cust_Code>GRB050</d:cust_Code><d:cust_Email>axxx@xxx.com</d:cust_Email><d:cust_Qty m:type="Edm.Int64">1</d:cust_Qty><d:cust_Name>white cream2</d:cust_Name><d:cust_ReqID>001153734192</d:cust_ReqID><d:cust_Cellphone>085810089</d:cust_Cellphone></m:properties></content></entry></feed>
and this is information from my general splitter

and this is my scriptBuildSignature
/*
 The integration developer needs to create the method processData 
 This method takes Message object of package com.sap.gateway.ip.core.customdev.util 
which includes helper methods useful for the content developer:
The methods available are:
    public java.lang.Object getBody()
	public void setBody(java.lang.Object exchangeBody)
    public java.util.Map<java.lang.String,java.lang.Object> getHeaders()
    public void setHeaders(java.util.Map<java.lang.String,java.lang.Object> exchangeHeaders)
    public void setHeader(java.lang.String name, java.lang.Object value)
    public java.util.Map<java.lang.String,java.lang.Object> getProperties()
    public void setProperties(java.util.Map<java.lang.String,java.lang.Object> exchangeProperties) 
    public void setProperty(java.lang.String name, java.lang.Object value)
    public java.util.List<com.sap.gateway.ip.core.customdev.util.SoapHeader> getSoapHeaders()
    public void setSoapHeaders(java.util.List<com.sap.gateway.ip.core.customdev.util.SoapHeader> soapHeaders) 
       public void clearSoapHeaders()
 */
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.*;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException;


def hmac_sha256(String secretKey, String data) {
 try {
    Mac mac = Mac.getInstance("HmacSHA256");
    SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256");
    mac.init(secretKeySpec);
    byte[] digest = mac.doFinal(data.getBytes());
    return digest;
   } catch (InvalidKeyException e) {
    throw new RuntimeException("Invalid key exception while converting to HMac SHA256");
  }
}


def Message processData(Message message) {
    //Property
    map = message.getProperties();
    def appKey = map.get("app_key");
    
    //Body 
    def body = message.getBody(String.class);
    def md5 = '';
    
    body = body.replaceAll("\r", "\\r");
    body = body.replaceAll("\n", "\\n");
    
    message.setProperty("oldBody", body);
    
    md5 = MessageDigest.getInstance("MD5").digest(body.bytes).encodeHex().toString();
    
    def milliseconds = System.currentTimeMillis();


    def secretKey = "post-" + md5 + "-" + milliseconds + "-/api/v1/orders/openorder";
    message.setProperty("secretKey", secretKey);
    
    def hash = hmac_sha256(appKey, secretKey);
    def encodedData = hash.encodeBase64().toString();
    
    message.setBody("");
	
	message.setHeader("milliseconds", milliseconds);
	message.setHeader("signature", encodedData);
    return message;
}


thank you

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member76287
Participant
0 Likes

got it the problem

thanks a lot

former_member608139
Active Participant
0 Likes

Probably the +rp+erty "app_key" cannot be found or is not filled with any value ( stay null)

    map =message.getProperties();
    def appKey = map.get("app_key");