Search in sources :

Example 1 with GreetMeResponse

use of org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse 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)

Aggregations

JAXBContext (javax.xml.bind.JAXBContext)1 Service (javax.xml.ws.Service)1 WebServiceException (javax.xml.ws.WebServiceException)1 XMLService (org.apache.hello_world_xml_http.wrapped.XMLService)1 GreetMe (org.apache.hello_world_xml_http.wrapped.types.GreetMe)1 GreetMeResponse (org.apache.hello_world_xml_http.wrapped.types.GreetMeResponse)1 Test (org.junit.Test)1