使用CXF和具有未发布元数据的WSDL的java
我使用CXF与WCF中的WSDL进行通信。WCF方面的东西是在tutorial之后创建的。Java代码是使用Maven脚本生成的
我已经使用HTTPS进行了加密。我已经开始工作了。但是,我希望在WCF端关闭WSDL元数据,并且仍然能够使用Java端与服务对话
目前,我可以使用以下代码从Java端访问元数据发布服务:
URL wsdlLocation = new URL("https://server.com:7010/Hservice?wsdl");
HttpsURLConnection connection = (HttpsURLConnection) wsdlLocation.openConnection();
HService service = new HService(wsdlLocation);
HAdminService calc = service.getHAdminService();
... (authentication using WSS4JOutInterceptor code and unrelated code here)
System.out.println(calc.add(new Double(5), new Double(5)));
但是,当我在WCF端关闭元数据发布时,会出现以下错误:
Exception in thread "main" javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:90)
at javax.xml.ws.Service.<init>(Service.java:56)
at com.blah.hservice.v_1_0.HService.<init>(HService.java:49)
at Main.main(Main.java:85)`
wsdl所在的页面在元数据发布关闭的情况下显示此内容(这是一个摘录):
This is a Windows© Communication Foundation service.
Metadata publishing for this service is currently disabled.
If you have access to the service, you can enable metadata publishing by completing the following steps to modify your web or application configuration file:
我希望能够搜索“未发布的CXF元数据”,并看到很多人这样做。。。但是没有发现任何东西。如何在不发布WSDL的情况下与此服务通信
# 1 楼答案
我使用CXF2.6.5生成的客户端代码实现了这一点
确保QName(第一个参数)与getHAdminService()方法引用的QName匹配。bindingId(第二个参数)应该是SOAPBinding接口(javax.xml.ws.soap.SOAPBinding)中定义的常量之一
# 2 楼答案
你真的有两个选择: