Search in sources :

Example 21 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.

the class ConfiguredEndpointTest method doTestConfiguredClientEndpoint.

private void doTestConfiguredClientEndpoint() {
    javax.xml.ws.Service service = new SOAPService();
    Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
    JaxWsClientProxy eih = (JaxWsClientProxy) Proxy.getInvocationHandler(greeter);
    Client client = eih.getClient();
    JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl) client.getEndpoint();
    org.apache.cxf.service.ServiceImpl svc = (org.apache.cxf.service.ServiceImpl) endpoint.getService();
    assertEquals("Unexpected bean name.", SERVICE_NAME.toString(), svc.getBeanName());
    List<Interceptor<? extends Message>> interceptors = svc.getInInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-in", findTestInterceptor(interceptors).getId());
    interceptors = svc.getOutInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-out", findTestInterceptor(interceptors).getId());
    interceptors = svc.getInFaultInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-in-fault", findTestInterceptor(interceptors).getId());
    interceptors = svc.getOutFaultInterceptors();
    assertEquals("Unexpected number of interceptors: " + interceptors, 1, interceptors.size());
    assertEquals("Unexpected interceptor id.", "service-out-fault", findTestInterceptor(interceptors).getId());
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Message(org.apache.cxf.message.Message) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) Greeter(org.apache.hello_world_soap_http.Greeter) Client(org.apache.cxf.endpoint.Client) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor)

Example 22 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.

the class ConfiguredEndpointTest method doTestDefaultClientEndpoint.

private void doTestDefaultClientEndpoint() {
    javax.xml.ws.Service service = new SOAPService();
    Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
    JaxWsClientProxy eih = (JaxWsClientProxy) Proxy.getInvocationHandler(greeter);
    Client client = eih.getClient();
    JaxWsEndpointImpl endpoint = (JaxWsEndpointImpl) client.getEndpoint();
    assertEquals("Unexpected bean name", PORT_NAME.toString() + ".endpoint", endpoint.getBeanName());
    assertTrue("Unexpected value for property validating", !Boolean.TRUE.equals(endpoint.get(Message.SCHEMA_VALIDATION_ENABLED)));
    // System.out.println("endpoint interceptors");
    List<Interceptor<? extends Message>> interceptors = endpoint.getInInterceptors();
    printInterceptors("in", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = endpoint.getOutInterceptors();
    printInterceptors("out", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = endpoint.getInFaultInterceptors();
    printInterceptors("inFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = endpoint.getOutFaultInterceptors();
    printInterceptors("outFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    // System.out.println("service interceptors");
    org.apache.cxf.service.ServiceImpl svc = (org.apache.cxf.service.ServiceImpl) endpoint.getService();
    assertEquals("Unexpected bean name", SERVICE_NAME.toString(), svc.getBeanName());
    interceptors = svc.getInInterceptors();
    printInterceptors("in", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = svc.getOutInterceptors();
    printInterceptors("out", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = svc.getInFaultInterceptors();
    printInterceptors("inFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
    interceptors = svc.getOutFaultInterceptors();
    printInterceptors("outFault", interceptors);
    assertNull("Unexpected test interceptor", findTestInterceptor(interceptors));
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) Message(org.apache.cxf.message.Message) JaxWsEndpointImpl(org.apache.cxf.jaxws.support.JaxWsEndpointImpl) Greeter(org.apache.hello_world_soap_http.Greeter) Client(org.apache.cxf.endpoint.Client) AbstractPhaseInterceptor(org.apache.cxf.phase.AbstractPhaseInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor)

Example 23 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.

the class EndpointReferenceTest method testEndpointReferenceGetPort.

@Test
public void testEndpointReferenceGetPort() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        DOMSource erXML = new DOMSource(doc);
        EndpointReference endpointReference = EndpointReference.readFrom(erXML);
        WebServiceFeature[] wfs = new WebServiceFeature[] {};
        Greeter greeter = endpointReference.getPort(Greeter.class, wfs);
        String response = greeter.greetMe("John");
        assertEquals("Hello John", response);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) InputStream(java.io.InputStream) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceFeature(javax.xml.ws.WebServiceFeature) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 24 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.

the class EndpointReferenceTest method testBindingProviderSOAPBinding.

@Test
public void testBindingProviderSOAPBinding() throws Exception {
    javax.xml.ws.Service s = javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
    assertNotNull(s);
    Greeter greeter = s.getPort(Greeter.class);
    BindingProvider bindingProvider = (BindingProvider) greeter;
    EndpointReference er = bindingProvider.getEndpointReference();
    assertNotNull(er);
    // If the BindingProvider instance has a binding that is either SOAP 1.1/HTTP or SOAP
    // 1.2/HTTP, then a W3CEndpointReference MUST be returned.
    assertTrue(er instanceof W3CEndpointReference);
}
Also used : QName(javax.xml.namespace.QName) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Greeter(org.apache.hello_world_soap_http.Greeter) BindingProvider(javax.xml.ws.BindingProvider) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 25 with Greeter

use of org.apache.hello_world_soap_http.Greeter in project cxf by apache.

the class EndpointReferenceTest method testServiceGetPortUsingEndpointReference.

/*
     * Any JAX-WS supported epr metadata MUST match the Service instances
     * ServiceName, otherwise a WebServiceExeption MUST be thrown. Any JAX-WS
     * supported epr metadata MUST match the PortName for the sei, otherwise a
     * WebServiceException MUST be thrown. If the Service instance has an
     * associated WSDL, its WSDL MUST be used to determine any binding
     * information, anyWSDL in a JAX-WS suppported epr metadata MUST be ignored.
     * If the Service instance does not have a WSDL, then any WSDL inlined in
     * the JAX-WS supported metadata of the epr MUST be used to determine
     * binding information. If there is not enough metadata in the Service
     * instance or in the epr metadata to determine a port, then a
     * WebServiceException MUST be thrown.
     */
@Test
public void testServiceGetPortUsingEndpointReference() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        javax.xml.ws.Service s = javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        DOMSource erXML = new DOMSource(doc);
        EndpointReference endpointReference = EndpointReference.readFrom(erXML);
        WebServiceFeature[] wfs = new WebServiceFeature[] {};
        Greeter greeter = s.getPort(endpointReference, Greeter.class, wfs);
        String response = greeter.greetMe("John");
        assertEquals("Hello John", response);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceFeature(javax.xml.ws.WebServiceFeature) Test(org.junit.Test)

Aggregations

Greeter (org.apache.hello_world_soap_http.Greeter)104 Test (org.junit.Test)78 SOAPService (org.apache.hello_world_soap_http.SOAPService)55 URL (java.net.URL)47 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)24 BindingProvider (javax.xml.ws.BindingProvider)23 SOAPServiceBogusAddressTest (org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest)21 SOAPServiceMultiPortTypeTest (org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest)21 Service (javax.xml.ws.Service)19 Client (org.apache.cxf.endpoint.Client)17 Endpoint (javax.xml.ws.Endpoint)13 QName (javax.xml.namespace.QName)10 Bus (org.apache.cxf.Bus)10 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)10 ExecutorService (java.util.concurrent.ExecutorService)9 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)7 File (java.io.File)6 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)6 GreetMeLaterResponse (org.apache.hello_world_soap_http.types.GreetMeLaterResponse)6 InvocationHandler (java.lang.reflect.InvocationHandler)5