use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class WSDLServiceBuilderTest method testExtensions.
@Test
public void testExtensions() throws Exception {
setUpWSDL("hello_world_ext.wsdl", 0);
String ns = "http://apache.org/hello_world_soap_http";
QName pingMeOpName = new QName(ns, "pingMe");
QName greetMeOpName = new QName(ns, "greetMe");
QName faultName = new QName(ns, "pingMeFault");
// portType extensions
InterfaceInfo ii = serviceInfo.getInterface();
assertEquals(2, ii.getExtensionAttributes().size());
assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_BOOLEAN));
assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, ii.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, ii.getExtensor(UnknownExtensibilityElement.class).getElementType());
// portType/operation extensions
OperationInfo oi = ii.getOperation(pingMeOpName);
assertPortTypeOperationExtensions(oi, true);
assertPortTypeOperationExtensions(ii.getOperation(greetMeOpName), false);
// portType/operation/[input|output|fault] extensions
assertPortTypeOperationMessageExtensions(oi, true, true, faultName);
assertPortTypeOperationMessageExtensions(ii.getOperation(greetMeOpName), false, true, null);
// service extensions
assertEquals(1, serviceInfo.getExtensionAttributes().size());
assertNotNull(serviceInfo.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, serviceInfo.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, serviceInfo.getExtensor(UnknownExtensibilityElement.class).getElementType());
// service/port extensions
EndpointInfo ei = serviceInfo.getEndpoints().iterator().next();
assertEquals(1, ei.getExtensionAttributes().size());
assertNotNull(ei.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, ei.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, ei.getExtensor(UnknownExtensibilityElement.class).getElementType());
// binding extensions
BindingInfo bi = ei.getBinding();
// REVISIT: bug in wsdl4j?
// getExtensionAttributes on binding element returns an empty map
// assertEquals(1, bi.getExtensionAttributes().size());
// assertNotNull(bi.getExtensionAttribute(EXTENSION_ATTR_STRING));
assertEquals(1, bi.getExtensors(UnknownExtensibilityElement.class).size());
assertEquals(EXTENSION_ELEM, bi.getExtensor(UnknownExtensibilityElement.class).getElementType());
// binding/operation extensions
BindingOperationInfo boi = bi.getOperation(pingMeOpName);
assertBindingOperationExtensions(boi, true);
assertBindingOperationExtensions(bi.getOperation(greetMeOpName), false);
// binding/operation/[input|output|fault] extensions
assertBindingOperationMessageExtensions(boi, true, true, faultName);
assertBindingOperationMessageExtensions(bi.getOperation(greetMeOpName), false, true, null);
control.verify();
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class WSDLServiceBuilderTest method testBindingOperationInfo.
@Test
public void testBindingOperationInfo() throws Exception {
setUpBasic();
BindingInfo bindingInfo = serviceInfo.getBindings().iterator().next();
Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
assertNotNull(bindingOperationInfos);
assertEquals(bindingOperationInfos.size(), 4);
LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());
QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
BindingOperationInfo sayHi = bindingInfo.getOperation(name);
assertNotNull(sayHi);
assertEquals(sayHi.getName(), name);
name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
BindingOperationInfo greetMe = bindingInfo.getOperation(name);
assertNotNull(greetMe);
assertEquals(greetMe.getName(), name);
name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMeOneWay");
BindingOperationInfo greetMeOneWay = bindingInfo.getOperation(name);
assertNotNull(greetMeOneWay);
assertEquals(greetMeOneWay.getName(), name);
name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
BindingOperationInfo pingMe = bindingInfo.getOperation(name);
assertNotNull(pingMe);
assertEquals(pingMe.getName(), name);
control.verify();
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ServiceProcessor method processPort.
private JavaPort processPort(JavaModel model, ServiceInfo si, EndpointInfo port) throws ToolException {
BindingInfo binding = port.getBinding();
String portType = binding.getInterface().getName().getLocalPart();
JavaInterface intf = PortTypeProcessor.getInterface(context, si, binding.getInterface());
JavaPort jport = new JavaPort(NameUtil.mangleNameToClassName(port.getName().getLocalPart()));
jport.setPackageName(intf.getPackageName());
jport.setPortName(port.getName().getLocalPart());
jport.setBindingAdress(port.getAddress());
jport.setBindingName(binding.getName().getLocalPart());
jport.setPortType(portType);
jport.setInterfaceClass(intf.getName());
bindingType = getBindingType(binding);
if (bindingType == null) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_SPECIFY_ONE_PROTOCOL", LOG, binding.getName());
throw new ToolException(msg);
}
if (isSoapBinding()) {
SoapBinding spbd = SOAPBindingUtil.getProxy(SoapBinding.class, this.bindingObj);
jport.setStyle(SOAPBindingUtil.getSoapStyle(spbd.getStyle()));
jport.setTransURI(spbd.getTransportURI());
}
Collection<BindingOperationInfo> operations = binding.getOperations();
for (BindingOperationInfo bop : operations) {
processOperation(model, bop, binding);
}
jport.setJavaDoc(port.getDocumentation());
JAXWSBinding bind = port.getExtensor(JAXWSBinding.class);
if (bind != null) {
jport.setMethodName(bind.getMethodName());
jport.setJavaDoc(bind.getMethodJavaDoc());
}
return jport;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ServiceWSDLBuilder method buildBinding.
protected void buildBinding(Definition definition, Collection<BindingInfo> bindingInfos, Collection<PortType> portTypes) {
for (BindingInfo bindingInfo : bindingInfos) {
final Binding binding = definition.createBinding();
addDocumentation(binding, bindingInfo.getDocumentation());
binding.setUndefined(false);
for (PortType portType : portTypes) {
if (portType.getQName().equals(bindingInfo.getInterface().getName())) {
binding.setPortType(portType);
break;
}
}
binding.setQName(bindingInfo.getName());
if (!bindingInfo.getName().getNamespaceURI().equals(definition.getTargetNamespace())) {
addNamespace(bindingInfo.getName().getNamespaceURI(), definition);
}
buildBindingOperation(definition, binding, bindingInfo.getOperations());
addExtensibilityElements(definition, binding, getWSDL11Extensors(bindingInfo));
definition.addBinding(binding);
}
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class DocLiteralInInterceptorTest method testUnmarshalSourceDataWrapped.
@Test
public void testUnmarshalSourceDataWrapped() throws Exception {
XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/docLitWrappedReq.xml"));
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
XMLStreamReader filteredReader = new PartialXMLStreamReader(reader, new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"));
// advance the xml reader to the message parts
StaxUtils.read(filteredReader);
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
Message m = new MessageImpl();
// request to keep the document as wrapped
m.put(DocLiteralInInterceptor.KEEP_PARAMETERS_WRAPPER, true);
Exchange exchange = new ExchangeImpl();
Service service = control.createMock(Service.class);
exchange.put(Service.class, service);
EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding()).anyTimes();
EasyMock.expect(service.size()).andReturn(0).anyTimes();
EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
exchange.put(Endpoint.class, endpoint);
// wrapped
OperationInfo operationInfo = new OperationInfo();
MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo"));
messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "personId"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName(NS, "ssn"), null));
messageInfo.getMessagePart(0).setConcreteName(new QName(NS, "personId"));
messageInfo.getMessagePart(1).setConcreteName(new QName(NS, "ssn"));
operationInfo.setInput("inputName", messageInfo);
// wrapper
OperationInfo operationInfoWrapper = new OperationInfo();
MessageInfo messageInfoWrapper = new MessageInfo(operationInfo, Type.INPUT, new QName(NS, "foo"));
messageInfoWrapper.addMessagePart(new MessagePartInfo(new QName(NS, "GetPerson"), null));
messageInfoWrapper.getMessagePart(0).setConcreteName(new QName(NS, "GetPerson"));
operationInfoWrapper.setInput("inputName", messageInfoWrapper);
operationInfoWrapper.setUnwrappedOperation(operationInfo);
ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com", "service")).anyTimes();
InterfaceInfo interfaceInfo = control.createMock(InterfaceInfo.class);
EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes();
EasyMock.expect(interfaceInfo.getName()).andReturn(new QName("http://foo.com", "interface")).anyTimes();
BindingInfo bindingInfo = new BindingInfo(serviceInfo, "");
BindingOperationInfo boi = new BindingOperationInfo(bindingInfo, operationInfoWrapper);
exchange.put(BindingOperationInfo.class, boi);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
BindingInfo binding = control.createMock(BindingInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(binding.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes();
EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com", "endpoint")).anyTimes();
EasyMock.expect(endpointInfo.getProperty("URI", URI.class)).andReturn(new URI("dummy")).anyTimes();
List<OperationInfo> operations = new ArrayList<>();
EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes();
m.setExchange(exchange);
m.put(Message.SCHEMA_VALIDATION_ENABLED, false);
m.setContent(XMLStreamReader.class, reader);
control.replay();
new DocLiteralInInterceptor().handleMessage(m);
MessageContentsList params = (MessageContentsList) m.getContent(List.class);
// we expect a wrapped document
assertEquals(1, params.size());
Map<String, String> ns = new HashMap<>();
ns.put("ns", NS);
XPathUtils xu = new XPathUtils(ns);
assertEquals("hello", xu.getValueString("//ns:GetPerson/ns:personId", ((DOMSource) params.get(0)).getNode().getFirstChild()));
assertEquals("1234", xu.getValueString("//ns:GetPerson/ns:ssn", ((DOMSource) params.get(0)).getNode().getFirstChild()));
}
Aggregations