Question

Is it possible to invoke a web service in Java without using the JAX-WS API but a specific runtime implementation API such as CXF specific API?

I have Metro on my classpath an its causing issues when I use the JAX-WS API so I want to specify the exact JAX-WS API implementation to use dynamically when invoking the service

Thank u

Était-ce utile?

La solution

Most likely, all the JAX-WS implementations have some sort of proprietary API that can be used to create services that would use their specific implementation and bypass the JAX-WS provider discovery mechanisms. In most cases, the discovered Providers are likely a wrapper onto those API's.

For CXF on the client side, that would be the JaxWsProxyFactoryBean:

http://cxf.apache.org/javadoc/latest/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.html

which can be used to create the Proxy objects from the JAX-WS generated interfaces.

Autres conseils

You may build your request in plain XML and do SOAP request. To build XML structure, you may use SoapUI, where you can import WSDL which gives you xml input structure. Copy that in to java class,append the request params where ever necessary and fire the request. You don't require any Jax-WS API. Only the problem with this aproach is you need to write XML parser for inputs and outputs

[update] different solution

I use Java API to use framework features, but need to create client jars for given service and add to class path.

URL wsdlURL = new URL("http://localhost/myweb/services/xyz_services?wsdl");
        QName SERVICE_NAME = new QName("http://service.sa.com/","portname");
        Service service = Service.create(wsdlURL, SERVICE_NAME);

        TestService client = service.getPort(TestService.class);
        client.execute();

Provided your service looks like below

package com.sa.service;
        Inteface TestService{
            public void execute();
        }

You can create client class using wsimport(Java tool) from command line and then jar them and add to classpath

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top