我需要通过 https 从 xfire 客户端使用 ws-security(用户名令牌)调用axis2 Web 服务。我可以通过xfire 动态客户端进行练习,但使用 wsdl 基本客户端没有运气(即从 wsdl 生成 java 存根)。谁能指出我可能出了什么问题(存根,ws-security 其他)?
例外:
线程“主”org.codehaus.xfire.XFireRuntimeException 中的异常:无法调用服务。嵌套异常是 org.codehaus.xfire.fault.XFireFault:找不到操作的端点引用 (EPR) 是 https://localhost /services/DataServiceSample2 和 WSA 操作 = org.codehaus.xfire.fault.XFireFault:找不到操作的端点参考 (EPR) 是 https://localhost/services/DataServiceSample2 和 WSA 操作 =
代码:
public static void main(String[] args) throws MalformedURLException {
ProtocolSocketFactory easy = new EasySSLProtocolSocketFactory();
Protocol protocol = new Protocol("https", easy, 9443);
Protocol.registerProtocol("https", protocol);
ObjectServiceFactory serviceFactory = new ObjectServiceFactory();
serviceFactory.setStyle("message");
Service serviceModel = serviceFactory.create(DataServiceSample2PortType.class);
XFireProxyFactory factory = new XFireProxyFactory();
DataServiceSample2PortType service = (DataServiceSample2PortType) factory.create(serviceModel, "https://localhost:9443/services/DataServiceSample2");
Client client = Client.getInstance(service);
client.addOutHandler(new DOMOutHandler());
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.setProperty(WSHandlerConstants.USER, "admin");
properties.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
properties.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, PasswordHandler.class.getName());
client.addOutHandler(new WSS4JOutHandler(properties));
sab.TopCustomerResponse topCustomersInCalifornia = service.topCustomersInCalifornia(null);
}