public void testJava() throws Exception {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service = factory.getService(wsdl, null, null, null, null);
WSIFPort port = service.getPort();
WSIFOperation operation;
WSIFMessage inputMessage;
WSIFMessage outputMessage;
WSIFMessage faultMessage;
String tempString;
Object part;
boolean operationSucceeded;
/**********************************************************
* Test calling a service that takes a char as an argument
**********************************************************/
operation = port.createOperation("setCharOperation");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
inputMessage.setObjectPart("in", "a");
operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
assertTrue("setChar failed!!", operationSucceeded);
if (operationSucceeded) {
assertTrue(
"setChar did not return a boolean",
outputMessage.getObjectPart("out") instanceof Boolean);
assertTrue("setChar did not return true", ((Boolean) outputMessage.getObjectPart("out")).booleanValue());
debug("setChar returned "+ outputMessage.getObjectPart("out"));
} else {
debug("operation failed");
}
/**********************************************************
* Test calling a service that returns a char
**********************************************************/
operation = port.createOperation("getCharOperation");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
inputMessage.setBooleanPart("in", true);
operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
assertTrue("getChar failed!!", operationSucceeded);
if (operationSucceeded) {
assertTrue(
"getChar did not return a String",
outputMessage.getObjectPart("out") instanceof String);
debug("getChar returned "+ outputMessage.getObjectPart("out"));
} else {
debug("operation failed");
}
/*************************************************************
* Test calling a service that takes a char[][] as an argument
*************************************************************/
operation = port.createOperation("setCharArrayOperation");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
String[][] sa = new String[][] {{"a", "b"},{"d", "e", "g"}};
inputMessage.setObjectPart("in", sa);
operationSucceeded =
operation.executeRequestResponseOperation(
inputMessage,
outputMessage,
faultMessage);
assertTrue("setCharArray failed!!", operationSucceeded);
if (operationSucceeded) {
assertTrue(
"setCharArray did not return a boolean",
outputMessage.getObjectPart("out") instanceof Boolean);
assertTrue("getCharArray did not return true", ((Boolean) outputMessage.getObjectPart("out")).booleanValue());
debug("setCharArray returned "+ outputMessage.getObjectPart("out"));
} else {
debug("operation failed");
}
/*************************************************************
* Test calling a service that returns a char[][]
*************************************************************/
operation = port.createOperation("getCharArrayOperation");
inputMessage = operation.createInputMessage();
outputMessage = operation.createOutputMessage();
faultMessage = operation.createFaultMessage();
inputMessage.setBooleanPart("in", true);