use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class ServiceWSDLBuilder method buildBindingOperation.
protected void buildBindingOperation(Definition def, Binding binding, Collection<BindingOperationInfo> bindingOperationInfos) {
BindingOperation bindingOperation = null;
for (BindingOperationInfo bindingOperationInfo : bindingOperationInfos) {
bindingOperation = def.createBindingOperation();
addDocumentation(bindingOperation, bindingOperationInfo.getDocumentation());
bindingOperation.setName(bindingOperationInfo.getName().getLocalPart());
for (Operation operation : CastUtils.cast(binding.getPortType().getOperations(), Operation.class)) {
if (operation.getName().equals(bindingOperation.getName())) {
bindingOperation.setOperation(operation);
break;
}
}
buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
buildBindingFault(def, bindingOperation, bindingOperationInfo.getFaults());
addExtensibilityAttributes(def, bindingOperation, bindingOperationInfo.getExtensionAttributes());
addExtensibilityElements(def, bindingOperation, getWSDL11Extensors(bindingOperationInfo));
binding.addBindingOperation(bindingOperation);
}
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class WSDLServiceBuilder method buildBinding.
public BindingInfo buildBinding(ServiceInfo service, Binding binding) {
BindingInfo bi = null;
StringBuilder ns = new StringBuilder(100);
BindingFactory factory = WSDLServiceUtils.getBindingFactory(binding, bus, ns);
if (factory instanceof WSDLBindingFactory) {
WSDLBindingFactory wFactory = (WSDLBindingFactory) factory;
bi = wFactory.createBindingInfo(service, binding, ns.toString());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
}
if (bi == null) {
boolean onlyExtensors = false;
if (factory instanceof AbstractBindingFactory) {
bi = ((AbstractBindingFactory) factory).createBindingInfo(service, ns.toString(), null);
onlyExtensors = true;
} else {
bi = new BindingInfo(service, ns.toString());
}
bi.setName(binding.getQName());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("binding operation name is " + bop.getName());
}
String inName = null;
String outName = null;
if (bop.getBindingInput() != null) {
inName = bop.getBindingInput().getName();
}
if (bop.getBindingOutput() != null) {
outName = bop.getBindingOutput().getName();
}
BindingOperationInfo bop2 = null;
if (onlyExtensors) {
bop2 = bi.getOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()));
} else {
bop2 = bi.buildOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()), inName, outName);
if (bop2 != null) {
bi.addOperation(bop2);
}
}
if (bop2 != null) {
copyExtensors(bop2, bop.getExtensibilityElements());
copyExtensionAttributes(bop2, bop);
if (bop.getBindingInput() != null) {
copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
copyExtensionAttributes(bop2.getInput(), bop.getBindingInput());
handleHeader(bop2.getInput());
}
if (bop.getBindingOutput() != null) {
copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
copyExtensionAttributes(bop2.getOutput(), bop.getBindingOutput());
handleHeader(bop2.getOutput());
}
for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
BindingFaultInfo bif = bop2.getFault(new QName(service.getTargetNamespace(), f.getName()));
copyExtensors(bif, bop.getBindingFault(f.getName()).getExtensibilityElements());
copyExtensionAttributes(bif, bop.getBindingFault(f.getName()));
}
}
}
}
service.addBinding(bi);
DescriptionInfo d = service.getDescription();
if (null != d) {
d.getDescribed().add(bi);
}
return bi;
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class DocLiteralInInterceptorTest method testUnmarshalSourceData.
@Test
public void testUnmarshalSourceData() throws Exception {
XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/multiPartDocLitBareReq.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();
Exchange exchange = new ExchangeImpl();
Service service = control.createMock(Service.class);
exchange.put(Service.class, service);
EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding());
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);
OperationInfo operationInfo = new OperationInfo();
operationInfo.setProperty("operation.is.synthetic", Boolean.TRUE);
MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName("http://foo.com", "bar"));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo1"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo2"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo3"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo4"), null));
for (MessagePartInfo mpi : messageInfo.getMessageParts()) {
mpi.setMessageContainer(messageInfo);
}
operationInfo.setInput("inputName", messageInfo);
BindingOperationInfo boi = new BindingOperationInfo(null, operationInfo);
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();
ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes();
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();
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);
assertEquals(4, params.size());
assertEquals("StringDefaultInputElem", ((DOMSource) params.get(0)).getNode().getFirstChild().getNodeName());
assertEquals("IntParamInElem", ((DOMSource) params.get(1)).getNode().getFirstChild().getNodeName());
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class WSDLServiceBuilderTest method testBare.
@Test
public void testBare() throws Exception {
setUpWSDL(BARE_WSDL_PATH, 0);
BindingInfo bindingInfo = null;
bindingInfo = serviceInfo.getBindings().iterator().next();
Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
assertNotNull(bindingOperationInfos);
assertEquals(bindingOperationInfos.size(), 1);
LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());
QName name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
BindingOperationInfo greetMe = bindingInfo.getOperation(name);
assertNotNull(greetMe);
assertEquals("greetMe OperationInfo name error", greetMe.getName(), name);
assertFalse("greetMe should be a Unwrapped operation ", greetMe.isUnwrappedCapable());
assertNotNull(serviceInfo.getXmlSchemaCollection());
control.verify();
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class WSDLServiceBuilderTest method testBindingMessageInfo.
@Test
public void testBindingMessageInfo() throws Exception {
setUpBasic();
BindingInfo bindingInfo = null;
bindingInfo = serviceInfo.getBindings().iterator().next();
QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
BindingOperationInfo sayHi = bindingInfo.getOperation(name);
BindingMessageInfo input = sayHi.getInput();
assertNotNull(input);
assertEquals(input.getMessageInfo().getName().getLocalPart(), "sayHiRequest");
assertEquals(input.getMessageInfo().getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
assertEquals(input.getMessageInfo().getMessageParts().size(), 1);
assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(), "in");
assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
QName elementName = input.getMessageInfo().getMessageParts().get(0).getElementQName();
assertEquals(elementName.getLocalPart(), "sayHi");
assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
BindingMessageInfo output = sayHi.getOutput();
assertNotNull(output);
assertEquals(output.getMessageInfo().getName().getLocalPart(), "sayHiResponse");
assertEquals(output.getMessageInfo().getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
assertEquals(output.getMessageInfo().getMessageParts().size(), 1);
assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(), "out");
assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
assertTrue(output.getMessageInfo().getMessageParts().get(0).isElement());
elementName = output.getMessageInfo().getMessageParts().get(0).getElementQName();
assertEquals(elementName.getLocalPart(), "sayHiResponse");
assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
assertTrue(sayHi.getFaults().isEmpty());
name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
BindingOperationInfo pingMe = bindingInfo.getOperation(name);
assertNotNull(pingMe);
assertEquals(1, pingMe.getFaults().size());
BindingFaultInfo fault = pingMe.getFaults().iterator().next();
assertNotNull(fault);
assertEquals(fault.getFaultInfo().getName().getLocalPart(), "pingMeFault");
assertEquals(fault.getFaultInfo().getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
assertEquals(fault.getFaultInfo().getMessageParts().size(), 1);
assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getLocalPart(), "faultDetail");
assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getNamespaceURI(), "http://apache.org/hello_world_soap_http");
assertTrue(fault.getFaultInfo().getMessageParts().get(0).isElement());
elementName = fault.getFaultInfo().getMessageParts().get(0).getElementQName();
assertEquals(elementName.getLocalPart(), "faultDetail");
assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
control.verify();
}
Aggregations