use of org.apache.cxf.service.model.BindingOperationInfo 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 e) {
throw new ServiceConstructionException(e);
} catch (NoSuchMethodException e) {
throw new ServiceConstructionException(e);
}
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class JAXWSMethodInvokerTest method prepareJAXWSMethodInvoker.
private JAXWSMethodInvoker prepareJAXWSMethodInvoker(Exchange ex, Object serviceObject, Method serviceMethod) throws Throwable {
EasyMock.reset(factory);
factory.create(ex);
EasyMock.expectLastCall().andReturn(serviceObject).anyTimes();
factory.release(ex, serviceObject);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(factory);
BindingOperationInfo boi = new BindingOperationInfo();
ex.put(BindingOperationInfo.class, boi);
Service serviceClass = EasyMock.createMock(Service.class);
serviceClass.size();
EasyMock.expectLastCall().andReturn(0).anyTimes();
serviceClass.isEmpty();
EasyMock.expectLastCall().andReturn(true).anyTimes();
ex.put(Service.class, serviceClass);
MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class);
serviceClass.get(MethodDispatcher.class.getName());
EasyMock.expectLastCall().andReturn(md).anyTimes();
md.getMethod(boi);
EasyMock.expectLastCall().andReturn(serviceMethod).anyTimes();
EasyMock.replay(md);
EasyMock.replay(serviceClass);
// initialize the contextCache
ex.getInMessage().getContextualProperty("dummy");
return new JAXWSMethodInvoker(factory);
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class ServiceModelUtilsTest method testGetOperationInputPartNamesRpc.
@Test
public void testGetOperationInputPartNamesRpc() throws Exception {
getService(getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"), RPCLitGreeterImpl.class, new QName("http://apache.org/hello_world_rpclit", "SoapPortRPCLit"));
BindingOperationInfo operation = ServiceModelUtil.getOperation(message.getExchange(), "greetMe");
assertNotNull(operation);
List<String> names = ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo());
assertNotNull(names);
assertEquals(1, names.size());
assertEquals("in", names.get(0));
operation = ServiceModelUtil.getOperation(message.getExchange(), "sayHi");
assertNotNull(operation);
names = ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo());
assertNotNull(names);
assertEquals(0, names.size());
operation = ServiceModelUtil.getOperation(message.getExchange(), "greetUs");
assertNotNull(operation);
names = ServiceModelUtil.getOperationInputPartNames(operation.getOperationInfo());
assertNotNull(names);
assertEquals(2, names.size());
// System.err.println(names);
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class DispatchTest method testFindOperationWithSource.
@Test
public void testFindOperationWithSource() throws Exception {
ServiceImpl service = new ServiceImpl(getBus(), getClass().getResource("/wsdl/hello_world.wsdl"), serviceName, null);
Dispatch<Source> disp = service.createDispatch(portName, Source.class, Service.Mode.MESSAGE);
disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
disp.getRequestContext().put("find.dispatch.operation", Boolean.TRUE);
d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
BindingOperationVerifier bov = new BindingOperationVerifier();
((DispatchImpl<?>) disp).getClient().getOutInterceptors().add(bov);
Document doc = StaxUtils.read(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml"));
DOMSource source = new DOMSource(doc);
Source res = disp.invoke(source);
assertNotNull(res);
BindingOperationInfo boi = bov.getBindingOperationInfo();
assertNotNull(boi);
assertEquals(new QName("http://apache.org/hello_world_soap_http", "sayHi"), boi.getName());
}
use of org.apache.cxf.service.model.BindingOperationInfo in project cxf by apache.
the class SOAPLoggingTest method testSoap.
@Test
public void testSoap() {
DefaultLogEventMapper mapper = new DefaultLogEventMapper();
Message message = new MessageImpl();
ExchangeImpl exchange = new ExchangeImpl();
ServiceInfo service = new ServiceInfo();
BindingInfo info = new BindingInfo(service, "bindingId");
SoapBinding value = new SoapBinding(info);
exchange.put(Binding.class, value);
OperationInfo opInfo = new OperationInfo();
opInfo.setName(new QName("http://my", "Operation"));
BindingOperationInfo boi = new BindingOperationInfo(info, opInfo);
exchange.put(BindingOperationInfo.class, boi);
message.setExchange(exchange);
LogEvent event = mapper.map(message);
Assert.assertEquals("{http://my}Operation", event.getOperationName());
}
Aggregations