Search in sources :

Example 1 with GreetMe

use of org.apache.hello_world_xml_http.wrapped.types.GreetMe in project cxf by apache.

the class XMLMessageOutInterceptorTest method testWrapOut.

@Test
public void testWrapOut() throws Exception {
    GreetMe greetMe = new GreetMe();
    greetMe.setRequestType("tli");
    params.add(greetMe);
    common("/wsdl/hello_world_xml_wrapped.wsdl", new QName(wrapNs, "XMLPort"), GreetMe.class);
    BindingInfo bi = super.serviceInfo.getBinding(new QName(wrapNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(wrapNs, "greetMe"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);
    out.handleMessage(xmlMessage);
    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);
    assertEquals(wrapGreetMeQName.getNamespaceURI(), dxr.getNamespaceURI());
    assertEquals(wrapGreetMeQName.getLocalPart(), dxr.getLocalName());
    StaxUtils.toNextElement(dxr);
    StaxUtils.toNextText(dxr);
    assertEquals(greetMe.getRequestType(), dxr.getText());
}
Also used : GreetMe(org.apache.hello_world_xml_http.wrapped.types.GreetMe) 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) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) Test(org.junit.Test)

Example 2 with GreetMe

use of org.apache.hello_world_xml_http.wrapped.types.GreetMe in project cxf by apache.

the class DispatchXMLClientServerTest method testJAXBMESSAGE.

@Test
public void testJAXBMESSAGE() throws Exception {
    Service service = Service.create(SERVICE_NAME);
    assertNotNull(service);
    service.addPort(PORT_NAME, "http://cxf.apache.org/bindings/xformat", "http://localhost:" + port + "/XMLService/XMLDispatchPort");
    GreetMe gm = new GreetMe();
    gm.setRequestType("CXF");
    JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class);
    Dispatch<Object> disp = service.createDispatch(PORT_NAME, ctx, Service.Mode.MESSAGE);
    GreetMeResponse resp = (GreetMeResponse) disp.invoke(gm);
    assertNotNull(resp);
    assertEquals("Hello CXF", resp.getResponseType());
    try {
        disp.invoke(null);
        fail("Should have thrown a fault");
    } catch (WebServiceException ex) {
    // expected
    }
}
Also used : GreetMe(org.apache.hello_world_xml_http.wrapped.types.GreetMe) WebServiceException(javax.xml.ws.WebServiceException) Service(javax.xml.ws.Service) XMLService(org.apache.hello_world_xml_http.wrapped.XMLService) JAXBContext(javax.xml.bind.JAXBContext) GreetMeResponse(org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse) Test(org.junit.Test)

Example 3 with GreetMe

use of org.apache.hello_world_xml_http.wrapped.types.GreetMe in project cxf by apache.

the class XMLMessageInInterceptorTest method testHandleMessageWrapped.

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

Aggregations

GreetMe (org.apache.hello_world_xml_http.wrapped.types.GreetMe)3 Test (org.junit.Test)3 QName (javax.xml.namespace.QName)2 JAXBContext (javax.xml.bind.JAXBContext)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 Service (javax.xml.ws.Service)1 WebServiceException (javax.xml.ws.WebServiceException)1 BindingInfo (org.apache.cxf.service.model.BindingInfo)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 DepthXMLStreamReader (org.apache.cxf.staxutils.DepthXMLStreamReader)1 XMLService (org.apache.hello_world_xml_http.wrapped.XMLService)1 GreetMeResponse (org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse)1