Search in sources :

Example 1 with SOAPRPCHeaderService

use of org.apache.header_test.rpc.SOAPRPCHeaderService in project cxf by apache.

the class HeaderClientServerTest method testRPCInHeader.

@Test
public void testRPCInHeader() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
    assertNotNull(wsdl);
    SOAPRPCHeaderService service = new SOAPRPCHeaderService(wsdl, new QName("http://apache.org/header_test/rpc", "SOAPRPCHeaderService"));
    assertNotNull(service);
    TestRPCHeader proxy = service.getSoapRPCHeaderPort();
    try {
        HeaderMessage header = new HeaderMessage();
        header.setHeaderVal("header");
        for (int idx = 0; idx < 2; idx++) {
            String returnVal = proxy.testHeader1(header, "part");
            assertNotNull(returnVal);
            assertEquals("part/header", returnVal);
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPRPCHeaderService(org.apache.header_test.rpc.SOAPRPCHeaderService) QName(javax.xml.namespace.QName) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) HeaderMessage(org.apache.header_test.rpc.types.HeaderMessage) TestRPCHeader(org.apache.header_test.rpc.TestRPCHeader) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 2 with SOAPRPCHeaderService

use of org.apache.header_test.rpc.SOAPRPCHeaderService in project cxf by apache.

the class ProviderHeaderClientServerTest method testRPCInHeader.

@Test
public void testRPCInHeader() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
    assertNotNull(wsdl);
    SOAPRPCHeaderService service = new SOAPRPCHeaderService(wsdl, new QName("http://apache.org/header_test/rpc", "SOAPRPCHeaderService"));
    assertNotNull(service);
    Dispatch<SOAPMessage> dispatch = service.createDispatch(new QName("http://apache.org/header_test/rpc", "SoapRPCHeaderPort"), javax.xml.soap.SOAPMessage.class, Service.Mode.MESSAGE);
    MessageFactory factory = MessageFactory.newInstance();
    InputStream is = getClass().getClassLoader().getResourceAsStream("./soapheader_rpc_provider/sayHelloMsg.xml");
    SOAPMessage inMessage = factory.createMessage(null, is);
    SOAPMessage response = dispatch.invoke(inMessage);
    is.close();
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    response.writeTo(bout);
    assertTrue(new String(bout.toByteArray()).contains("part/header"));
}
Also used : SOAPRPCHeaderService(org.apache.header_test.rpc.SOAPRPCHeaderService) MessageFactory(javax.xml.soap.MessageFactory) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 3 with SOAPRPCHeaderService

use of org.apache.header_test.rpc.SOAPRPCHeaderService in project cxf by apache.

the class HeaderClientServerTest method testRPCInOutHeader.

@Test
public void testRPCInOutHeader() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/soapheader_rpc.wsdl");
    assertNotNull(wsdl);
    SOAPRPCHeaderService service = new SOAPRPCHeaderService(wsdl, new QName("http://apache.org/header_test/rpc", "SOAPRPCHeaderService"));
    assertNotNull(service);
    TestRPCHeader proxy = service.getSoapRPCHeaderPort();
    try {
        HeaderMessage header = new HeaderMessage();
        Holder<HeaderMessage> holder = new Holder<>(header);
        for (int idx = 0; idx < 2; idx++) {
            holder.value.setHeaderVal("header" + idx);
            String returnVal = proxy.testInOutHeader("part" + idx, holder);
            assertNotNull(returnVal);
            assertEquals("header" + idx, returnVal);
            assertEquals("part" + idx, holder.value.getHeaderVal());
        }
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : SOAPRPCHeaderService(org.apache.header_test.rpc.SOAPRPCHeaderService) QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) HeaderMessage(org.apache.header_test.rpc.types.HeaderMessage) TestRPCHeader(org.apache.header_test.rpc.TestRPCHeader) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Aggregations

URL (java.net.URL)3 QName (javax.xml.namespace.QName)3 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)3 SOAPRPCHeaderService (org.apache.header_test.rpc.SOAPRPCHeaderService)3 Test (org.junit.Test)3 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 Endpoint (javax.xml.ws.Endpoint)2 TestRPCHeader (org.apache.header_test.rpc.TestRPCHeader)2 HeaderMessage (org.apache.header_test.rpc.types.HeaderMessage)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 MessageFactory (javax.xml.soap.MessageFactory)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 Holder (javax.xml.ws.Holder)1