use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class CodeFirstTest method createService.
private Definition createService(boolean wrapped) throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(Hello.class);
bean.setWrapped(wrapped);
Service service = bean.create();
InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
assertEquals(5, i.getOperations().size());
ServerFactoryBean svrFactory = new ServerFactoryBean();
svrFactory.setBus(bus);
svrFactory.setServiceFactory(bean);
svrFactory.setAddress(address);
svrFactory.create();
Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings();
assertEquals(1, bindings.size());
ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
return wsdlBuilder.build();
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class CodeFirstWSDLTest method testOnlyRootElementOnFaultBean.
@Test
public void testOnlyRootElementOnFaultBean() throws Exception {
// CXF-4016
EndpointImpl ep = (EndpointImpl) Endpoint.publish("local://foo4016", new CXF4016Impl());
ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, ep.getService().getServiceInfos().get(0));
Definition def = wsdlBuilder.build();
Document d = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
this.addNamespace("http://www.example.org/contract/DoubleIt", "tns");
// org.apache.cxf.helpers.XMLUtils.printDOM(d);
assertXPathEquals("//xsd:element/@ref", new QName("http://www.example.org/contract/DoubleIt", "CustomMessageBean"), d);
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder 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());
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class JaxWsServerFactoryBeanTest method testJaxwsServiceClass.
@Test
public void testJaxwsServiceClass() throws Exception {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(CalculatorPortType.class);
factory.setServiceBean(new CalculatorImpl());
String address = "http://localhost:9001/jaxwstest";
factory.setAddress(address);
Server server = factory.create();
Endpoint endpoint = server.getEndpoint();
ServiceInfo service = endpoint.getEndpointInfo().getService();
assertNotNull(service);
Bus bus = factory.getBus();
Definition def = new ServiceWSDLBuilder(bus, service).build();
WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
Document doc = wsdlWriter.getDocument(def);
Map<String, String> ns = new HashMap<>();
ns.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
ns.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
XPathUtils xpather = new XPathUtils(ns);
xpather.isExist("/wsdl:definitions/wsdl:binding/soap:binding", doc, XPathConstants.NODE);
xpather.isExist("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='add']/soap:operation", doc, XPathConstants.NODE);
xpather.isExist("/wsdl:definitions/wsdl:service/wsdl:port[@name='add']/soap:address[@location='" + address + "']", doc, XPathConstants.NODE);
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder 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);
}
}
Aggregations