use of javax.wsdl.Definition in project cxf by apache.
the class WSDLGetUtils method updateWSDLKeyDefinition.
/**
* Create a wsdl Definition object from the endpoint information and register
* it in the local data structure for future reference.
*
* @param bus CXF's hub for access to internal constructs
* @param mp a map of known wsdl Definition objects
* @param message
* @param smp a map of known xsd SchemaReference objects
* @param base the request URL
* @param endpointInfo information for a web service 'port' inside of a service
* @throws WSDLException
*/
protected void updateWSDLKeyDefinition(Bus bus, Map<String, Definition> mp, Message message, Map<String, SchemaReference> smp, String base, EndpointInfo endpointInfo) throws WSDLException {
if (!mp.containsKey("")) {
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, endpointInfo.getService());
builder.setUseSchemaImports(MessageUtils.getContextualBoolean(message, WSDL_CREATE_IMPORTS, false));
// base file name is ignored if createSchemaImports == false!
builder.setBaseFileName(endpointInfo.getService().getName().getLocalPart());
Definition def = builder.build(new HashMap<String, SchemaInfo>());
mp.put("", def);
updateDefinition(bus, def, mp, smp, base, "", "");
}
}
use of javax.wsdl.Definition in project cxf by apache.
the class PolicyAnnotationTest method testAnnotationImplNoInterface.
@org.junit.Test
public void testAnnotationImplNoInterface() throws Exception {
Bus bus = BusFactory.getDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setBus(bus);
factory.setServiceBean(new TestImplNoInterface());
factory.setStart(false);
List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");
LocalTransportFactory f = new LocalTransportFactory();
f.getUriPrefixes().add("http");
f.setTransportIds(tp);
Server s = factory.create();
try {
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
Definition def = builder.build();
WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();
Map<String, String> ns = new HashMap<>();
ns.put("wsdl", WSDLConstants.NS_WSDL11);
ns.put("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
ns.put("wsp", Constants.URI_POLICY_13_NS);
XPathUtils xpu = new XPathUtils(ns);
// org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/" + "wsp:PolicyReference[@URI='#TestImplNoInterfaceServiceSoapBindingBindingPolicy']", wsdl).getLength());
final EndpointPolicy policy = bus.getExtension(PolicyEngine.class).getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
assertNotNull(policy);
} finally {
bus.shutdown(true);
}
}
use of javax.wsdl.Definition in project cxf by apache.
the class ServiceModelUtilTest method setUp.
@Before
public void setUp() throws Exception {
String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
Definition def = wsdlReader.readWSDL(wsdlUrl);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
if (serv != null) {
service = serv;
break;
}
}
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
}
use of javax.wsdl.Definition in project cxf by apache.
the class SoapBindingFactoryTest method testFactory.
@Test
public void testFactory() throws Exception {
Definition d = createDefinition("/wsdl_soap/hello_world.wsdl");
Bus bus = getMockBus();
BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP11, bus);
bus.getExtension(BindingFactoryManager.class);
expectLastCall().andReturn(bfm).anyTimes();
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
ServiceInfo serviceInfo = builder.buildServices(d, new QName("http://apache.org/hello_world_soap_http", "SOAPService")).get(0);
BindingInfo bi = serviceInfo.getBindings().iterator().next();
assertTrue(bi instanceof SoapBindingInfo);
SoapBindingInfo sbi = (SoapBindingInfo) bi;
assertEquals("document", sbi.getStyle());
assertTrue(WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equalsIgnoreCase(sbi.getTransportURI()));
assertTrue(sbi.getSoapVersion() instanceof Soap11);
BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap_http", "sayHi"));
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("", sboi.getAction());
BindingMessageInfo input = boi.getInput();
SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
assertEquals("literal", bodyInfo.getUse());
List<MessagePartInfo> parts = bodyInfo.getParts();
assertNotNull(parts);
assertEquals(1, parts.size());
}
use of javax.wsdl.Definition in project cxf by apache.
the class CodeFirstWSDLTest method testDocumentationOnImpl.
@Test
public void testDocumentationOnImpl() throws Exception {
// CXF-3092
EndpointImpl ep = (EndpointImpl) Endpoint.publish("local://foo", new CXF3092Impl());
ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, ep.getService().getServiceInfos().get(0));
Definition def = wsdlBuilder.build();
Document d = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
// org.apache.cxf.helpers.XMLUtils.printDOM(d);
assertXPathEquals("//wsdl:definitions/wsdl:documentation", "My top level documentation", d.getDocumentElement());
assertXPathEquals("//wsdl:definitions/wsdl:service/wsdl:documentation", "My Service documentation", d.getDocumentElement());
assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My binding doc", d.getDocumentElement());
JaxwsServiceBuilder builder = new JaxwsServiceBuilder();
builder.setServiceClass(CXF3092Impl.class);
ServiceInfo serviceInfo = builder.createService();
wsdlBuilder = new ServiceWSDLBuilder(bus, serviceInfo);
def = wsdlBuilder.build();
d = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
// org.apache.cxf.helpers.XMLUtils.printDOM(d);
assertXPathEquals("//wsdl:definitions/wsdl:documentation", "My top level documentation", d.getDocumentElement());
assertXPathEquals("//wsdl:definitions/wsdl:service/wsdl:documentation", "My Service documentation", d.getDocumentElement());
assertXPathEquals("//wsdl:definitions/wsdl:binding/wsdl:documentation", "My binding doc", d.getDocumentElement());
}
Aggregations