use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testWebSeviceException.
@Test
public void testWebSeviceException() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(WebServiceExceptionTestImpl.class);
Service service = bean.create();
ServiceInfo si = service.getServiceInfos().get(0);
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, si);
Definition def = builder.build();
Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
assertInvalid("/wsdl:definitions/wsdl:message[@name='WebServiceException']", wsdl);
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testBareBug.
@Test
public void testBareBug() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(org.apache.cxf.test.TestInterfacePort.class);
Service service = bean.create();
ServiceInfo si = service.getServiceInfos().get(0);
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, si);
Definition def = builder.build();
Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
NodeList nodeList = assertValid("/wsdl:definitions/wsdl:types/xsd:schema" + "[@targetNamespace='http://cxf.apache.org/" + "org.apache.cxf.test.TestInterface/xsd']" + "/xsd:element[@name='getMessage']", wsdl);
assertEquals(1, nodeList.getLength());
assertValid("/wsdl:definitions/wsdl:message[@name='setMessage']" + "/wsdl:part[@name = 'parameters'][@element='ns1:setMessage']", wsdl);
assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']", wsdl);
assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" + "/wsdl:part[@name = 'return'][@element='ns1:charEl_return']", wsdl);
assertValid("/wsdl:definitions/wsdl:message[@name='echoCharResponse']" + "/wsdl:part[@name = 'z'][@element='ns1:charEl_z']", wsdl);
assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']" + "/wsdl:part[@name = 'x'][@element='ns1:charEl_x']", wsdl);
assertValid("/wsdl:definitions/wsdl:message[@name='echoChar']" + "/wsdl:part[@name = 'y'][@element='ns1:charEl_y']", wsdl);
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class PolicyAnnotationTest method testAnnotationImplNoInterfacePolicies.
@org.junit.Test
public void testAnnotationImplNoInterfacePolicies() throws Exception {
Bus bus = BusFactory.getDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setBus(bus);
factory.setServiceBean(new TestImplWithPoliciesNoInterface());
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='#TestImplWithPoliciesNoInterfaceServiceSoapBindingBindingPolicy']", wsdl).getLength());
final EndpointPolicy policy = bus.getExtension(PolicyEngine.class).getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
assertNotNull(policy);
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class PolicyAnnotationTest method testAnnotations.
@org.junit.Test
public void testAnnotations() throws Exception {
Bus bus = BusFactory.getDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setBus(bus);
factory.setServiceBean(new TestImpl());
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);
check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestImplPortPortPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input", "echoIntPortTypeOpInputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output", "echoIntPortTypeOpOutputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestImplServiceSoapBindingBindingPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input", "echoIntBindingOpInputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output", "echoIntBindingOpOutputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestImplServiceServicePolicy");
assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/wsdl:operation/" + "wsp:PolicyReference[@URI='#echoIntBindingOpPolicy']", wsdl).getLength());
EndpointPolicy policy = bus.getExtension(PolicyEngine.class).getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
assertNotNull(policy);
assertEquals(1, policy.getChosenAlternative().size());
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.wsdl11.ServiceWSDLBuilder in project cxf by apache.
the class PolicyAnnotationTest method testAnnotationsInterfaceAsClass.
@org.junit.Test
public void testAnnotationsInterfaceAsClass() throws Exception {
Bus bus = BusFactory.getDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setBus(bus);
factory.setServiceBean(new TestImpl());
factory.setServiceClass(TestInterface.class);
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);
check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestInterfacePortPortPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input", "echoIntPortTypeOpInputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output", "echoIntPortTypeOpOutputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestInterfaceServiceSoapBindingBindingPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input", "echoIntBindingOpInputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output", "echoIntBindingOpOutputPolicy");
check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestInterfaceServiceServicePolicy");
assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/wsdl:operation/" + "wsp:PolicyReference[@URI='#echoIntBindingOpPolicy']", wsdl).getLength());
} finally {
bus.shutdown(true);
}
}
Aggregations