use of org.apache.hello_world_rpclit.types.MyComplexStruct in project cxf by apache.
the class XMLStreamDataReaderTest method testReadRPC.
@Test
public void testReadRPC() throws Exception {
JAXBDataBinding db = getDataBinding(MyComplexStruct.class);
QName[] tags = { new QName("http://apache.org/hello_world_rpclit", "sendReceiveData") };
reader = getTestReader("../resources/greetMeRpcLitReq.xml");
assertNotNull(reader);
XMLStreamReader localReader = getTestFilteredReader(reader, tags);
DataReader<XMLStreamReader> dr = db.createReader(XMLStreamReader.class);
assertNotNull(dr);
Object val = dr.read(new QName("http://apache.org/hello_world_rpclit", "in"), localReader, MyComplexStruct.class);
assertNotNull(val);
assertTrue(val instanceof MyComplexStruct);
assertEquals("this is element 1", ((MyComplexStruct) val).getElem1());
assertEquals("this is element 2", ((MyComplexStruct) val).getElem2());
assertEquals(42, ((MyComplexStruct) val).getElem3());
}
use of org.apache.hello_world_rpclit.types.MyComplexStruct in project cxf by apache.
the class XMLStreamDataWriterTest method testWriteRPCLit2.
@Test
public void testWriteRPCLit2() throws Exception {
JAXBDataBinding db = getTestWriterFactory(MyComplexStruct.class);
DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
assertNotNull(dw);
MyComplexStruct val = new MyComplexStruct();
val.setElem1("This is element 1");
val.setElem2("This is element 2");
val.setElem3(1);
QName elName = new QName("http://apache.org/hello_world_rpclit/types", "in");
MessagePartInfo part = new MessagePartInfo(elName, null);
part.setElement(true);
part.setElementQName(elName);
dw.write(val, part, streamWriter);
streamWriter.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
StaxUtils.toNextElement(reader);
assertEquals(new QName("http://apache.org/hello_world_rpclit/types", "in"), reader.getName());
StaxUtils.nextEvent(reader);
StaxUtils.toNextElement(reader);
assertEquals(new QName("http://apache.org/hello_world_rpclit/types", "elem1"), reader.getName());
StaxUtils.nextEvent(reader);
StaxUtils.toNextText(reader);
assertEquals("This is element 1", reader.getText());
}
use of org.apache.hello_world_rpclit.types.MyComplexStruct in project cxf by apache.
the class Client method main.
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("please specify wsdl");
System.exit(1);
}
URL wsdlURL;
File wsdlFile = new File(args[0]);
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdlURL, SERVICE_NAME);
GreeterRPCLit greeter = (GreeterRPCLit) service.getPort(PORT_NAME, GreeterRPCLit.class);
System.out.println("Invoking sayHi...");
System.out.println("server responded with: " + greeter.sayHi());
System.out.println();
System.out.println("Invoking greetMe...");
System.out.println("server responded with: " + greeter.greetMe(System.getProperty("user.name")));
System.out.println();
MyComplexStruct argument = new MyComplexStruct();
MyComplexStruct retVal = null;
String str1 = "this is element 1";
String str2 = "this is element 2";
int int1 = 42;
argument.setElem1(str1);
argument.setElem2(str2);
argument.setElem3(int1);
System.out.println("Invoking sendReceiveData...");
retVal = greeter.sendReceiveData(argument);
System.out.println("Response from sendReceiveData operation :");
System.out.println("Element-1 : " + retVal.getElem1());
System.out.println("Element-2 : " + retVal.getElem2());
System.out.println("Element-3 : " + retVal.getElem3());
System.out.println();
System.exit(0);
}
use of org.apache.hello_world_rpclit.types.MyComplexStruct in project cxf by apache.
the class ClientServerRPCLitTest method testComplexType.
@Test
public void testComplexType() throws Exception {
SOAPServiceRPCLit service = new SOAPServiceRPCLit();
assertNotNull(service);
GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
updateAddressPort(greeter, PORT);
MyComplexStruct in = new MyComplexStruct();
in.setElem1("elem1");
in.setElem2("elem2");
in.setElem3(45);
try {
((BindingProvider) greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
MyComplexStruct out = greeter.sendReceiveData(in);
assertNotNull("no response received from service", out);
assertEquals(in.getElem1(), out.getElem1());
assertEquals(in.getElem2(), out.getElem2());
assertEquals(in.getElem3(), out.getElem3());
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
try {
in.setElem2("invalid");
greeter.sendReceiveData(in);
} catch (SOAPFaultException f) {
assertTrue(f.getCause() instanceof UnmarshalException);
}
}
Aggregations