日期:2014-05-16 浏览次数:20511 次
java2wsdl http://localhost:8081/cmdbuild/services/soap/Webservices?wsdl -uri
File file = new File(""); String path = file.getAbsolutePath(); ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem( path + "/WebContent/WEB-INF", null); WebservicesImplServiceStub stub = new WebservicesImplServiceStub(configContext, ENDPOINT); stub._getServiceClient().engageModule("rampart"); Options options = stub._getServiceClient().getOptions(); options.setUserName("admin"); options.setPassword("admin"); StAXOMBuilder builder = new StAXOMBuilder("C:/Users/liukai/Desktop/policy.xml"); options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, PolicyEngine.getPolicy(builder.getDocumentElement()));
<?xml version="1.0" encoding="UTF-8"?> <wsp:Policy wsu:Id="UTOverTransport" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-ssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> <wsp:ExactlyOne> <sp:SignedSupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"> <wsp:Policy> <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"> <wsp:Policy> <sp:HashPassword/> </wsp:Policy> </sp:UsernameToken> </wsp:Policy> </sp:SignedSupportingTokens> </wsp:ExactlyOne> </wsp:Policy>