I'm new to bpel and i'm just testing an If-else. The bpel file that i've been created using eclipse is: IfElseSample.bpel
It successfully deployed with no errors but when I try to test it using simple code like:
try {
tps.bpel.ifelse.IfElseSample_Service service = new tps.bpel.ifelse.IfElseSample_Service();
tps.bpel.ifelse.IfElseSample port = service.getIfElseSamplePort();
tps.bpel.ifelse.IfElseSampleRequest payload = new tps.bpel.ifelse.IfElseSampleRequest();
payload.setInput("John");
tps.bpel.ifelse.IfElseSampleResponse result = port.process(payload); //Exception occur here
System.out.println("Result = "+result);
} catch (Exception ex) {
System.out.println("Exception=> "+ex);
}
I got an exception error:
javax.xml.ws.soap.SOAPFaultException: axis2ns6575:selectionFailure
Also here is all of my eclipse project. and I use:
Thanks.
The BPEL standard requires variables to be initialized before XPath queries can be performed on it. In your example, you are assigning values to the uninitialized output variable. Since an uninitialized variable is empty, the XPath expression tns:result
does not select any node and thus throws a selectionFailure. You will need to initialize the variable first (e.g. in an <assign>
activity at the beginning). The Eclipse BPEL designer can do that for you (it usually asks you if you want to initialize the variable). The code should look roughly like this:
<bpel:assign>
<bpel:copy>
<bpel:from>
<bpel:literal>
<payload><tns:result/></payload>
</bpel:literal>
</bpel:from>
<bpel:to>$output.payload</bpel:to>
</bpel:copy>
</bpel:assign>