Java Code Examples for org.apache.cxf.frontend.ClientProxyFactoryBean#setServiceName()

The following examples show how to use org.apache.cxf.frontend.ClientProxyFactoryBean#setServiceName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Client.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
    String serviceURL;
    if (args != null && args.length > 0 && !"".equals(args[0])) {
        serviceURL = args[0];
    } else {
        serviceURL = "http://localhost:9000/Hello";
    }
    factory.setServiceName(new QName("http://server.hw.demo/", "HelloWorldService"));
    factory.setAddress(serviceURL);
    factory.setWsdlURL(serviceURL + "?wsdl");
    factory.getServiceFactory().setDataBinding(new AegisDatabinding());
    HelloWorld client = factory.create(HelloWorld.class);
    System.out.println("Invoke sayHi()....");
    System.out.println(client.sayHi(System.getProperty("user.name")));
    System.exit(0);
}
 
Example 2
Source File: ClientServerMiscTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleClientWithWsdl() throws Exception {
    QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
        "DocLitWrappedCodeFirstServicePort");
    QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
        "DocLitWrappedCodeFirstService");

    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
    factory.setWsdlURL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl");
    factory.setServiceName(servName);
    factory.setServiceClass(DocLitWrappedCodeFirstService.class);
    factory.setEndpointName(portName);

    DocLitWrappedCodeFirstService port = (DocLitWrappedCodeFirstService) factory.create();
    assertNotNull(port);

    String echoMsg = port.echo("Hello");
    assertEquals("Hello", echoMsg);
}
 
Example 3
Source File: ClientServerMiscTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleClientWithWsdlAndBindingId() throws Exception {
    QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
        "DocLitWrappedCodeFirstServicePort");
    QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
        "DocLitWrappedCodeFirstService");

    ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
    factory.setBindingId("http://cxf.apache.org/bindings/xformat");
    factory.setWsdlURL(ServerMisc.DOCLIT_CODEFIRST_URL_XMLBINDING + "?wsdl");
    factory.setServiceName(servName);
    factory.setServiceClass(DocLitWrappedCodeFirstService.class);
    factory.setEndpointName(portName);
    factory.setAddress(ServerMisc.DOCLIT_CODEFIRST_URL_XMLBINDING);
    DocLitWrappedCodeFirstService port = (DocLitWrappedCodeFirstService) factory.create();
    assertNotNull(port);
    assertEquals(factory.getBindingId(), "http://cxf.apache.org/bindings/xformat");
    assertTrue(ClientProxy.getClient(port).getEndpoint().getBinding() instanceof XMLBinding);

    String echoMsg = port.echo("Hello");
    assertEquals("Hello", echoMsg);
}