use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class SoapActionInterceptorTest method createBindingOperation.
private BindingOperationInfo createBindingOperation() {
ServiceInfo s = new ServiceInfo();
InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
s.setInterface(ii);
ii.addOperation(new QName("fooOp"));
BindingInfo b = new BindingInfo(s, "foo");
return b.buildOperation(new QName("fooOp"), null, null);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class TestBase method getTestService.
protected BindingInfo getTestService(String wsdlUrl, String port) throws Exception {
ServiceInfo service = getMockedServiceModel(getClass().getResource(wsdlUrl).toString());
assertNotNull(service);
BindingInfo binding = service.getEndpoint(new QName(service.getName().getNamespaceURI(), port)).getBinding();
assertNotNull(binding);
return binding;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class RPCOutInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
ServiceInfo si = getMockedServiceModel(this.getClass().getResource("/wsdl_soap/hello_world_rpc_lit.wsdl").toString());
BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
soapMessage.getExchange().put(BindingOperationInfo.class, boi);
control.reset();
Service service = control.createMock(Service.class);
EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
service.getDataBinding();
EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
service.getServiceInfos();
List<ServiceInfo> list = Arrays.asList(si);
EasyMock.expectLastCall().andReturn(list).anyTimes();
soapMessage.getExchange().put(Service.class, service);
soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
control.replay();
MyComplexStruct mcs = new MyComplexStruct();
mcs.setElem1("elem1");
mcs.setElem2("elem2");
mcs.setElem3(45);
MessageContentsList param = new MessageContentsList();
param.add(mcs);
soapMessage.setContent(List.class, param);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class SoapBindingFactoryTest method testFactory.
@Test
public void testFactory() throws Exception {
Definition d = createDefinition("/wsdl_soap/hello_world.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("http://apache.org/hello_world_soap_http", "SOAPService")).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("http://apache.org/hello_world_soap_http", "sayHi"));
SoapOperationInfo sboi = boi.getExtensor(SoapOperationInfo.class);
assertNotNull(sboi);
assertEquals("document", sboi.getStyle());
assertEquals("", 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());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class JaxWsServiceFactoryBean method initializeWSDLOperationsForProvider.
protected void initializeWSDLOperationsForProvider() {
Class<?> c = getProviderParameterType(getServiceClass());
if (c == null) {
throw new ServiceConstructionException(new Message("INVALID_PROVIDER_EXC", LOG));
}
if (getEndpointInfo() == null && isFromWsdl()) {
// most likely, they specified a WSDL, but for some reason
// did not give a valid ServiceName/PortName. For provider,
// we'll allow this since everything is bound directly to
// the invoke method, however, this CAN cause other problems
// such as addresses in the wsdl not getting updated and such
// so we'll WARN about it.....
List<QName> enames = new ArrayList<>();
for (ServiceInfo si : getService().getServiceInfos()) {
for (EndpointInfo ep : si.getEndpoints()) {
enames.add(ep.getName());
}
}
LOG.log(Level.WARNING, "COULD_NOT_FIND_ENDPOINT", new Object[] { getEndpointName(), enames });
}
try {
Method invoke = getServiceClass().getMethod("invoke", c);
QName catchAll = new QName("http://cxf.apache.org/jaxws/provider", "invoke");
// Bind every operation to the invoke method.
for (ServiceInfo si : getService().getServiceInfos()) {
si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
if (!isFromWsdl()) {
for (EndpointInfo ei : si.getEndpoints()) {
ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
}
}
for (BindingInfo bind : si.getBindings()) {
for (BindingOperationInfo bop : bind.getOperations()) {
OperationInfo o = bop.getOperationInfo();
if (bop.isUnwrappedCapable()) {
// force to bare, no unwrapping
bop.getOperationInfo().setUnwrappedOperation(null);
bop.setUnwrappedOperation(null);
}
if (o.getInput() != null) {
final List<MessagePartInfo> messageParts;
if (o.getInput().getMessagePartsNumber() == 0) {
MessagePartInfo inf = o.getInput().addMessagePart(o.getName());
inf.setConcreteName(o.getName());
messageParts = o.getInput().getMessageParts();
bop.getInput().setMessageParts(messageParts);
} else {
messageParts = o.getInput().getMessageParts();
}
for (MessagePartInfo inf : messageParts) {
inf.setTypeClass(c);
break;
}
}
if (o.getOutput() != null) {
final List<MessagePartInfo> messageParts;
if (o.getOutput().getMessagePartsNumber() == 0) {
MessagePartInfo inf = o.getOutput().addMessagePart(o.getName());
inf.setConcreteName(new QName(o.getName().getNamespaceURI(), o.getName().getLocalPart() + "Response"));
messageParts = o.getOutput().getMessageParts();
bop.getOutput().setMessageParts(messageParts);
} else {
messageParts = o.getOutput().getMessageParts();
}
for (MessagePartInfo inf : messageParts) {
inf.setTypeClass(c);
break;
}
}
getMethodDispatcher().bind(o, invoke);
}
BindingOperationInfo bop = bind.getOperation(catchAll);
if (bop == null) {
OperationInfo op = bind.getInterface().getOperation(catchAll);
if (op == null) {
op = bind.getInterface().addOperation(catchAll);
String name = catchAll.getLocalPart();
MessageInfo mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(), name + "Request"), MessageInfo.Type.INPUT);
op.setInput(catchAll.getLocalPart() + "Request", mInfo);
MessagePartInfo mpi = mInfo.addMessagePart("parameters");
mpi.setElement(true);
mpi.setTypeClass(c);
mpi.setTypeQName(Constants.XSD_ANYTYPE);
mInfo = op.createMessage(new QName(catchAll.getNamespaceURI(), name + "Response"), MessageInfo.Type.OUTPUT);
op.setOutput(name + "Response", mInfo);
mpi = mInfo.addMessagePart("parameters");
mpi.setElement(true);
mpi.setTypeClass(c);
mpi.setTypeQName(Constants.XSD_ANYTYPE);
BindingOperationInfo bo = new BindingOperationInfo(bind, op);
op.setProperty("operation.is.synthetic", Boolean.TRUE);
bo.setProperty("operation.is.synthetic", Boolean.TRUE);
bind.addOperation(bo);
}
}
}
}
} catch (SecurityException | NoSuchMethodException e) {
throw new ServiceConstructionException(e);
}
}
Aggregations