use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ServiceModelUtilTest method testGetSchema.
@Test
public void testGetSchema() throws Exception {
BindingInfo bindingInfo = serviceInfo.getBindings().iterator().next();
QName name = new QName(serviceInfo.getName().getNamespaceURI(), "inHeader");
BindingOperationInfo inHeader = bindingInfo.getOperation(name);
BindingMessageInfo input = inHeader.getInput();
assertNotNull(input);
assertEquals(input.getMessageInfo().getName().getLocalPart(), "inHeaderRequest");
assertEquals(input.getMessageInfo().getName().getNamespaceURI(), "http://org.apache.cxf/headers");
assertEquals(input.getMessageInfo().getMessageParts().size(), 2);
assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getLocalPart(), "inHeader");
assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getNamespaceURI(), "http://org.apache.cxf/headers");
assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getLocalPart(), "passenger");
assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getNamespaceURI(), "http://mycompany.example.com/employees");
assertTrue(input.getMessageInfo().getMessageParts().get(1).isElement());
MessagePartInfo messagePartInfo = input.getMessageInfo().getMessageParts().get(0);
SchemaInfo schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo);
assertEquals(schemaInfo.getNamespaceURI(), "http://org.apache.cxf/headers");
messagePartInfo = input.getMessageInfo().getMessageParts().get(1);
schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo);
assertEquals(schemaInfo.getNamespaceURI(), "http://mycompany.example.com/employees");
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class SoapBindingFactoryTest method testNoBodyParts.
@Test
public void testNoBodyParts() throws Exception {
Definition d = createDefinition("/wsdl_soap/no_body_parts.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("urn:org:apache:cxf:no_body_parts/wsdl", "NoBodyParts")).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("urn:org:apache:cxf:no_body_parts/wsdl", "operation1"));
assertNotNull(boi);
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertNull(sboi.getStyle());
assertEquals("", sboi.getAction());
BindingMessageInfo input = boi.getInput();
SoapBodyInfo bodyInfo = input.getExtensor(SoapBodyInfo.class);
assertNull(bodyInfo.getUse());
List<MessagePartInfo> parts = bodyInfo.getParts();
assertNotNull(parts);
assertEquals(0, parts.size());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class SoapBindingFactoryTest method testSoap12Factory.
@Test
public void testSoap12Factory() throws Exception {
Definition d = createDefinition("/wsdl_soap/hello_world_soap12.wsdl");
Bus bus = getMockBus();
BindingFactoryManager bfm = getBindingFactoryManager(WSDLConstants.NS_SOAP12, bus);
expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm);
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_soap12_http", "SOAPService")).get(0);
BindingInfo bi = serviceInfo.getBindings().iterator().next();
assertTrue(bi instanceof SoapBindingInfo);
SoapBindingInfo sbi = (SoapBindingInfo) bi;
assertEquals("document", sbi.getStyle());
assertEquals(WSDLConstants.NS_SOAP_HTTP_TRANSPORT, sbi.getTransportURI());
assertTrue(sbi.getSoapVersion() instanceof Soap12);
BindingOperationInfo boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "sayHi"));
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("sayHiAction", 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());
boi = sbi.getOperation(new QName("http://apache.org/hello_world_soap12_http", "pingMe"));
sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("", sboi.getAction());
Collection<BindingFaultInfo> faults = boi.getFaults();
assertEquals(1, faults.size());
BindingFaultInfo faultInfo = boi.getFault(new QName("http://apache.org/hello_world_soap12_http", "pingMeFault"));
assertNotNull(faultInfo);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class MustUnderstandInterceptorTest method testHandleMessageWithSoapHeader12Param.
@Test
public void testHandleMessageWithSoapHeader12Param() throws Exception {
prepareSoapMessage("test-soap-12-header.xml");
dsi.getUnderstoodHeaders().add(RESERVATION);
ServiceInfo serviceInfo = getMockedServiceModel(getClass().getResource("test-soap-12-header.wsdl").toString());
BindingInfo binding = serviceInfo.getBinding(new QName("http://org.apache.cxf/headers", "headerTesterSOAPBinding"));
BindingOperationInfo bop = binding.getOperation(new QName("http://org.apache.cxf/headers", "inHeader"));
soapMessage.getExchange().put(BindingOperationInfo.class, bop);
soapMessage.getInterceptorChain().doIntercept(soapMessage);
assertTrue("DummaySoapInterceptor getRoles has been called!", dsi.isCalledGetRoles());
assertTrue("DummaySoapInterceptor getUnderstood has been called!", dsi.isCalledGetUnderstood());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class DispatchImpl method addInvokeOperation.
private void addInvokeOperation(boolean oneWay) {
String name = oneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME;
ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();
OperationInfo opInfo = info.getInterface().addOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME);
MessageInfo mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Request"), Type.INPUT);
opInfo.setInput(name + "Request", mInfo);
MessagePartInfo mpi = mInfo.addMessagePart("parameters");
if (context == null) {
mpi.setTypeClass(cl);
}
mpi.setElement(true);
if (!oneWay) {
mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Response"), Type.OUTPUT);
opInfo.setOutput(name + "Response", mInfo);
mpi = mInfo.addMessagePart("parameters");
mpi.setElement(true);
if (context == null) {
mpi.setTypeClass(cl);
}
}
for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
bind.addOperation(bo);
}
}
Aggregations