Forum Stats

  • 3,872,463 Users
  • 2,266,426 Discussions
  • 7,911,211 Comments

Discussions

Java Embedding in BPEL

3741383
3741383 Member Posts: 20

Hello good day everyone,

right now I couldn't find a way to create SHA1 in BPEL using Java Embedding.

I saw a sample code of SHA1, but I couldn't understand how to read from XML element and set into XML element again.

so here is the SHA1 java code that i want to embed,

<span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">       </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">package</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> main</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">;</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">  <br/></span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">import</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> java</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">security</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">MessageDigest</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">;<br/></span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">import</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> java</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">security</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">NoSuchAlgorithmException</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">;</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> <br/><br/>  </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">public</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">class</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">HashTextTest<br/></span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">{</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">  </span><span class="com" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #858c93;">/** * @param args * @throws NoSuchAlgorithmException <br/>*/</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">public</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">static</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">void</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> main</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">String</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">[]</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> args</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">)</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">throws</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">NoSuchAlgorithmException<br/></span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">{</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">System</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">out</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">println</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">sha1</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="str" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">"test string to sha1"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">));</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> <br/></span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">}</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">  <br/></span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">static</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">String</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> sha1</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">String</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> input</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">)</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">throws</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">NoSuchAlgorithmException<br/></span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">{</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">MessageDigest</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> mDigest </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">=</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">MessageDigest</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">getInstance</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="str" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">"SHA1"</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">);</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">byte</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">[]</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> result </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">=</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> mDigest</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">digest</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">input</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">getBytes</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">());</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> <br/></span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">StringBuffer</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> sb </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">=</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">new</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">StringBuffer</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">();</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> <br/></span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">for</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">int</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> i </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">=</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="lit" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">0</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">;</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> i </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"><</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> result</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">length</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">;</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> i</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">++)<br/></span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">{</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> <br/>sb</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">append</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="typ" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #2b91af;">Integer</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">toString</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">((</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">result</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">[</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">i</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">]</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">&</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="lit" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">0xff</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">)</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">+</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="lit" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">0x100</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">,</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="lit" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">16</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">).</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">substring</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">(</span><span class="lit" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">1</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">));<br/></span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">}</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">  <br/></span><span class="kwd" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #101094;">return</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> sb</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">.</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">toString</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">();</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> <br/></span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">}</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> <br/></span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">}</span>

and this is the XML element that i want to use as a variable

<span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="tag" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;"><xsd:element</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #e64320;">name</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #0f74bd;">"pwd"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #e64320;">type</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #0f74bd;">"xsd:string"</span><span class="tag" style="font-style: inherit; font-weight: inherit; font-family: inherit; color: #7d2727;">/></span>

the element itself i have set to '12345678', and after i set the variable, i want to SHA1 then put it again into that element as XML.

sir @Martien van den Akker

if you know, maybe you could help me please sir..

thankyou

Tagged:
Amy Childress-Oracle

Best Answer

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,777 Bronze Crown
    edited Aug 22, 2018 5:26AM Answer ✓

    Hi,

    First off: this is quite a bit of functional code you want to try to do in embedded java. I'm not so fond of that. I'd use embedded java only for small, simple calculations or logging/auditing. The thing is that you can properly test and debug your code in embedded java. Also exception-handling cannot be done very nicely and declaratively. Since you apparently have a class that works as a stand-alone class, I'd register it as a spring bean. Possibly by adding a few accompanying beans that serve as  an input and result. See for instance my article here: https://blog.darwin-it.nl/2012/09/forget-about-wsif-welcome-spring.html This way you can add this bean declaratively to your composite and wire it to your bpel. That will generate a wsdl and a partnerlink for you. So you can just invoke it. That way you can test and debug the class stand alone in JDeveloper and then only need to get your input and output variables assigned properly.

    However, in your case you probably struggle with the lines

    XMLElement pwdElement = (XMLElement)getVariableData("setVar","/n8SetVar","/ns8:pwd");          String text = pwdElement.getTextContent();       

    and

    setVariableData("setVar","/n8SetVar","/ns8:setPwd",result);

    These are fields within a complex variable, where you need to set a proper xpath and message part. Two ways to solve this

    • If you want to keep these references, create a temporary assign statement with a copy-rule that assigns a dummy string to the particular element. If you select the assign and switch to the source, you'll find the copy rule with in the to-part the specific reference to the variable-part-element. Use that information to correct the getVariableData() and setVariableData() statements. Then remove the dummy assign. The error you posted noted '<faultcode>ns0:selectionFailure</faultcode>' which refers to one of these statements. Probably the first one. But I can't see in the stacktrace which line is meant (since the embedded java is compiled into a class during compilation of the bpel).
    • Much easier is to declare two xsd:string based variables to hold the password and store the result. Then first assign the value of the setVar variable to the variable 'password'. Then you just can refer to it with getVariableData('password'). No xpath needed. Then the setVariableData() becomes setVariableData('result'). I believe you don't need to convert the XMLElement to string. I have in one of my earlier projects a simple embedded sub-process that does logging like:
    <bpelx:inlineSubProcess name="SubProcessAddAuditTrailEntry">    <variables>      <variable name="logMessage" type="xsd:string"/>    </variables>    <sequence name="SequenceAddAuditTrailEntry">      <extensionActivity>        <bpelx:exec name="addAuditTrailEntry">          <![CDATA[final String bpelName = "HREmployeeEventToITProcess.bpel";  String logMessage = (String) getVariableData("logMessage");  addAuditTrailEntry(bpelName+": "+logMessage);]]>        </bpelx:exec>      </extensionActivity>    </sequence>  </bpelx:inlineSubProcess>

    You see here that I have a logMessage Variable based on xsd:string. I can just refer to it as String logMessage = (String) getVariableData("logMessage");  If I translate this to your situation I would probably get something like:

    <scope name="hashAPassword">    <variables>      <variable name="password" type="xsd:string"/>      <variable name="result" type="xsd:string"/>    </variables>    <sequence name="SequenceHashAPassword">      <extensionActivity>        <bpelx:exec name="addAuditTrailEntry">          <![CDATA[String text = (String) getVariableData("password");  try{        MessageDigest md = MessageDigest.getInstance("SHA1");            byte[] data = new byte[40];             md.update(text.getBytes("iso-8859-1"), 0, text.length());             data = md.digest();             StringBuffer buf = new StringBuffer();        for (int i = 0; i < data.length; i++) {                 int halfbyte = (data[i] >>> 4) & 0x0F;                 int two_halfs = 0;                 do {                     if ((0 <= halfbyte) && (halfbyte <= 9)) {                         buf.append((char) ('0' + halfbyte));  }                   else {                         buf.append((char) ('a' + (halfbyte - 10))); }                    halfbyte = data[i] & 0x0F;                } while (two_halfs++ < 1);       }       String result = buf.toString();     System.out.println(result);     setVariableData("result"); }catch(Exception e){ }]]>        </bpelx:exec>      </extensionActivity>    </sequence>  </scope>

    Add this to your BPEL. Then right click on the scope to transform it to an embedded subprocess and you can call it based on the originating message variables.

    Regards,

    Martien

    PS1: I just got back from vacation this week, so I have a pile of messages to follow-up on

    PS2: I did not test this, I rely on the proper functioning on your code and copy and pasted it in my example to refactor it.

    Amy Childress-Oracle3741383
«1

Answers

  • Hemanth Lakkaraju-Oracle
    Hemanth Lakkaraju-Oracle Member Posts: 412 Employee
    edited Jul 26, 2018 11:33PM

    Create a string variable in BPEL.

    Set the value of SHA1 to the variable using setVariableData() method.

    Re-assign the variable to the XMLElement in assign activity in BPEL.

    3741383
  • 3741383
    3741383 Member Posts: 20
    edited Jul 26, 2018 11:38PM

    hi

    thankyou for answering..

    do i have to put library for SHA1 as well?

    how i do i set the variable in Java method? i am really dont know java code

  • Hemanth Lakkaraju-Oracle
    Hemanth Lakkaraju-Oracle Member Posts: 412 Employee
    edited Jul 27, 2018 12:13AM

    Please refer to Section 13.2.3 and 13.3 here

  • 3741383
    3741383 Member Posts: 20
    edited Jul 30, 2018 11:28AM

    hello @Hemanth Lakkaraju-Oracle

    i finally figured out, how to use java embedded.. so here is my code

    XMLElement pwdElement = (XMLElement)getVariableData("setVar","/n8SetVar","/ns8:pwd");         

    String text = pwdElement.getTextContent();         

    try{   

        MessageDigest md = MessageDigest.getInstance("SHA1");       

        byte[] data = new byte[40];        

        md.update(text.getBytes("iso-8859-1"), 0, text.length());        

        data = md.digest();        

        StringBuffer buf = new StringBuffer();   

        for (int i = 0; i < data.length; i++) {        

            int halfbyte = (data[i] >>> 4) & 0x0F;        

            int two_halfs = 0;        

            do {        

                if ((0 <= halfbyte) && (halfbyte <= 9)) {        

                    buf.append((char) ('0' + halfbyte));  }      

                else {        

                    buf.append((char) ('a' + (halfbyte - 10))); }   

                    halfbyte = data[i] & 0x0F;       

            } while (two_halfs++ < 1);  

        }  

        String result = buf.toString();

        System.out.println(result);

        setVariableData("setVar","/n8SetVar","/ns8:setPwd",result);

    }catch(Exception e){

    }

    and i deployed successfully, but when i test it got this following error.. any ideas what happened?

    faultName: {{http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure} messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage} parts: {{ summary=<summary></summary>}

    <bpelFault><faultType>0</faultType><selectionFailure xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"><part name="summary"><summary></summary></part></selectionFailure></bpelFault>

  • Hemanth Lakkaraju-Oracle
    Hemanth Lakkaraju-Oracle Member Posts: 412 Employee
    edited Jul 30, 2018 11:35AM
    XMLElement pwdElement = (XMLElement)getVariableData("setVar","/n8SetVar","/ns8:pwd"); setVariableData("setVar","/n8SetVar","/ns8:setPwd",result); 

    This doesn't seem correct! It should be /ns8:SetVar.

    3741383
  • 3741383
    3741383 Member Posts: 20
    edited Jul 31, 2018 2:17AM

    yeah i mistyped that my apologies, but i have fixed that, but still got the following error

    "BPELFault" has not been caught by a catch block.

    faultName: {{http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure} messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage} parts: {{ summary=<summary></summary>}

    <bpelFault><faultType>0</faultType><selectionFailure xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"><part name="summary"><summary></summary></part></selectionFailure></bpelFault>

    This is the error code

    env:Fault xmlns:ns0="http://docs.oasis-open.org/wsbpel/2.0/process/executable" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <faultcode>ns0:selectionFailure</faultcode> <faultstring/> <faultactor/> <detail> <exception/> </detail> </env:Fault> oracle.j2ee.ws.client.jaxws.JRFSOAPFaultException: Client received SOAP Fault from server : null at oracle.j2ee.ws.client.jaxws.DispatchImpl.throwJAXWSSoapFaultException(DispatchImpl.java:1053) at oracle.j2ee.ws.client.jaxws.DispatchImpl.invoke(DispatchImpl.java:839) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.synchronousInvocationWithRetry(OracleDispatchImpl.java:235) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.invoke(OracleDispatchImpl.java:106) at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:358) at oracle.sysman.emSDK.webservices.wsdlparser.OperationInfoImpl.invokeWithDispatch(OperationInfoImpl.java:1004) at oracle.sysman.emas.model.wsmgt.PortName.invokeOperation(PortName.java:757) at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:809) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:402) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:319) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.el.parser.AstValue.invoke(AstValue.java:187) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297) at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53) at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1491) at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:111) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:395) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:115) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:111) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:395) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:115) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:971) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:439) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:219) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.sysman.emSDK.license.LicenseFilter.doFilter(LicenseFilter.java:101) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:211) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:133) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478) at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:303) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:208) at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.sysman.emas.fwk.MASConnectionFilter.doFilter(MASConnectionFilter.java:41) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:180) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.sysman.eml.app.AuditServletFilter.doFilter(AuditServletFilter.java:179) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.sysman.eml.app.EMRepLoginFilter.doFilter(EMRepLoginFilter.java:203) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.sysman.core.model.targetauth.EMLangPrefFilter.doFilter(EMLangPrefFilter.java:158) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.sysman.core.app.perf.PerfFilter.doFilter(PerfFilter.java:141) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.sysman.eml.app.ContextInitFilter.doFilter(ContextInitFilter.java:542) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:138) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:464) at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:121) at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:211) at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:163) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:60) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3748) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3714) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2283) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2182) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1499) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:263) at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

  • Hemanth Lakkaraju-Oracle
    Hemanth Lakkaraju-Oracle Member Posts: 412 Employee
    edited Jul 31, 2018 2:15AM

    Are you sure if the error is coming in this java embedding activity? Are you sure you are using the right variable structure? Can you paste a screenshot of your variable? One way to do it right is - create an assign pointing to the xpath. Go to source and use the variable name, part name and xpath from the assign statement to use it in setVariableData or getVariableData.

  • 3741383
    3741383 Member Posts: 20
    edited Jul 31, 2018 2:20AM

    here is the flow

    pastedImage_0.png

    pastedImage_1.png

    this is i want to add value to pwd, and after this i want java embedding to hash that value..

    here is the variable

    pastedImage_2.png

  • 3741383
    3741383 Member Posts: 20
    edited Jul 31, 2018 2:42AM

    im sure it came from java embed bcs when i cut the java embed, the flow almost done into insert to database, do you need more brief explanation about the flow, code or xpath?

  • Hemanth Lakkaraju-Oracle
    Hemanth Lakkaraju-Oracle Member Posts: 412 Employee
    edited Jul 31, 2018 2:43AM

    This seems to be an elementType variable. Try using:

    XMLElement pwdElement = (XMLElement)getVariableData("setVar","/n8:SetVar/ns8:pwd");

    setVariableData("setVar","/n8:SetVar/ns8:setPwd",result);

    3741383
This discussion has been closed.