Search in sources :

Example 1 with MyComplexStructType

use of org.apache.hello_world_xml_http.bare.types.MyComplexStructType in project cxf by apache.

the class XMLMessageOutInterceptorTest method testBareOutMultiWithRoot.

@Test
public void testBareOutMultiWithRoot() throws Exception {
    MyComplexStructType myComplexStruct = new MyComplexStructType();
    myComplexStruct.setElem1("elem1");
    myComplexStruct.setElem2("elem2");
    myComplexStruct.setElem3(45);
    params.add("tli");
    params.add(myComplexStruct);
    common("/wsdl/hello_world_xml_bare.wsdl", new QName(bareNs, "XMLPort"), MyComplexStructType.class);
    BindingInfo bi = super.serviceInfo.getBinding(new QName(bareNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(bareNs, "testMultiParamPart"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);
    out.handleMessage(xmlMessage);
    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);
    assertEquals(bareNs, dxr.getNamespaceURI());
    assertEquals("multiParamRootReq", dxr.getLocalName());
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);
    assertEquals(bareRequestTypeQName, dxr.getName());
    StaxUtils.nextEvent(dxr);
    if (StaxUtils.toNextText(dxr)) {
        assertEquals("tli", dxr.getText());
    }
    boolean foundRequest = false;
    while (true) {
        StaxUtils.nextEvent(dxr);
        StaxUtils.toNextElement(dxr);
        QName requestType = new QName(dxr.getNamespaceURI(), dxr.getLocalName());
        if (requestType.equals(bareMyComplexStructQName)) {
            foundRequest = true;
            break;
        }
    }
    assertEquals("found request type", true, foundRequest);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) XMLStreamReader(javax.xml.stream.XMLStreamReader) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) MyComplexStructType(org.apache.hello_world_xml_http.bare.types.MyComplexStructType) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) Test(org.junit.Test)

Example 2 with MyComplexStructType

use of org.apache.hello_world_xml_http.bare.types.MyComplexStructType in project cxf by apache.

the class XMLMessageOutInterceptorTest method testBareOutSingle.

@Test
public void testBareOutSingle() throws Exception {
    MyComplexStructType myComplexStruct = new MyComplexStructType();
    myComplexStruct.setElem1("elem1");
    myComplexStruct.setElem2("elem2");
    myComplexStruct.setElem3(45);
    params.add(myComplexStruct);
    common("/wsdl/hello_world_xml_bare.wsdl", new QName(bareNs, "XMLPort"), MyComplexStructType.class);
    BindingInfo bi = super.serviceInfo.getBinding(new QName(bareNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(bareNs, "sendReceiveData"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);
    out.handleMessage(xmlMessage);
    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);
    assertEquals(bareMyComplexStructTypeQName.getLocalPart(), dxr.getLocalName());
    StaxUtils.toNextElement(dxr);
    StaxUtils.toNextText(dxr);
    assertEquals(myComplexStruct.getElem1(), dxr.getText());
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) XMLStreamReader(javax.xml.stream.XMLStreamReader) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) MyComplexStructType(org.apache.hello_world_xml_http.bare.types.MyComplexStructType) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) Test(org.junit.Test)

Example 3 with MyComplexStructType

use of org.apache.hello_world_xml_http.bare.types.MyComplexStructType in project cxf by apache.

the class ClientServerXMLTest method testBareBasicConnection.

@Test
public void testBareBasicConnection() throws Exception {
    XMLService service = new XMLService();
    assertNotNull(service);
    String response1 = "Hello ";
    String response2 = "Bonjour";
    try {
        Greeter greeter = service.getPort(barePortName, Greeter.class);
        updateAddressPort(greeter, REG_PORT);
        String username = System.getProperty("user.name");
        String reply = greeter.greetMe(username);
        assertNotNull("no response received from service", reply);
        assertEquals(response1 + username, reply);
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response2, reply);
        MyComplexStructType argument = new MyComplexStructType();
        MyComplexStructType 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);
        retVal = greeter.sendReceiveData(argument);
        assertEquals(str1, retVal.getElem1());
        assertEquals(str2, retVal.getElem2());
        assertEquals(int1, retVal.getElem3());
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : XMLService(org.apache.hello_world_xml_http.bare.XMLService) Greeter(org.apache.hello_world_xml_http.bare.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) MyComplexStructType(org.apache.hello_world_xml_http.bare.types.MyComplexStructType) Test(org.junit.Test)

Example 4 with MyComplexStructType

use of org.apache.hello_world_xml_http.bare.types.MyComplexStructType in project cxf by apache.

the class XMLMessageInInterceptorTest method testHandleMessageOnBareMultiParam.

@Test
public void testHandleMessageOnBareMultiParam() throws Exception {
    String ns = "http://apache.org/hello_world_xml_http/bare";
    prepareMessage("/message-bare-multi-param.xml");
    common("/wsdl/hello_world_xml_bare.wsdl", new QName(ns, "XMLPort"), MyComplexStructType.class);
    OperationInfo op = serviceInfo.getInterface().getOperation(new QName(ns, "testMultiParamPart"));
    op.getInput().getMessagePartByIndex(0).setTypeClass(String.class);
    op.getInput().getMessagePartByIndex(1).setTypeClass(MyComplexStructType.class);
    in.handleMessage(xmlMessage);
    docLitIn.handleMessage(xmlMessage);
    List<?> list = xmlMessage.getContent(List.class);
    assertNotNull(list);
    assertEquals("expect 2 param", 2, list.size());
    assertEquals("method input in2 is MyComplexStructType", true, list.get(1) instanceof MyComplexStructType);
    assertEquals("method input in1 is String tli", true, ((String) list.get(0)).indexOf("tli") >= 0);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) MyComplexStructType(org.apache.hello_world_xml_http.bare.types.MyComplexStructType) Test(org.junit.Test)

Aggregations

MyComplexStructType (org.apache.hello_world_xml_http.bare.types.MyComplexStructType)4 Test (org.junit.Test)4 QName (javax.xml.namespace.QName)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 BindingInfo (org.apache.cxf.service.model.BindingInfo)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 DepthXMLStreamReader (org.apache.cxf.staxutils.DepthXMLStreamReader)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 Greeter (org.apache.hello_world_xml_http.bare.Greeter)1 XMLService (org.apache.hello_world_xml_http.bare.XMLService)1