How Can I Programmatically Add A Binding to CXF Client Code?
I am writing an ANT Task that tries to create a proxy for a CXF Web Service like below:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ProjectApi.class);
factory.setAddress("http://sasdk1/protex-sdk/v5_0/project");
ProjectApi projectApi =开发者_如何学编程 (ProjectApi)factory.create();
If I run it as a Main method in Eclipse, it runs fine.
However if I try to run as ANT task, it always fails with the following error:
org.apache.cxf.BusException:
No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered
How can I programmatically add this binding to the above code?
According to this, the cxf.xml file needs to be in the classpath of the client, in this case Ant.
I found a workaround that does not require placing the cxf.xml file under the Ant lib directory.
URL wsdlURL = null;
try {
wsdlURL = new URL("http://sasdk1/protex-sdk/v5_0/project?wsdl");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(-1);
}
QName SERVICE_NAME = new QName(
"urn:protex.company.com:sdk:v5.0:project",
"ProjectApiService");
Service service = Service.create(wsdlURL, SERVICE_NAME);
ProjectApi projectApi = service.getPort(ProjectApi.class);
精彩评论