use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class RMCaptureOutInterceptor method setTerminateSequence.
private void setTerminateSequence(Message msg, Identifier identifier, ProtocolVariation protocol) throws RMException {
TerminateSequenceType ts = new TerminateSequenceType();
ts.setIdentifier(identifier);
MessageContentsList contents = new MessageContentsList(new Object[] { protocol.getCodec().convertToSend(ts) });
msg.setContent(List.class, contents);
// create a new exchange for this output-only exchange
Exchange newex = new ExchangeImpl();
Exchange oldex = msg.getExchange();
newex.put(Bus.class, oldex.getBus());
newex.put(Endpoint.class, oldex.getEndpoint());
newex.put(Service.class, oldex.getEndpoint().getService());
newex.put(Binding.class, oldex.getEndpoint().getBinding());
newex.setConduit(oldex.getConduit(msg));
newex.setDestination(oldex.getDestination());
// Setup the BindingOperationInfo
RMEndpoint rmep = getManager().getReliableEndpoint(msg);
OperationInfo oi = rmep.getEndpoint(protocol).getEndpointInfo().getService().getInterface().getOperation(protocol.getConstants().getTerminateSequenceAnonymousOperationName());
BindingInfo bi = rmep.getBindingInfo(protocol);
BindingOperationInfo boi = bi.getOperation(oi);
newex.put(BindingInfo.class, bi);
newex.put(BindingOperationInfo.class, boi);
msg.setExchange(newex);
newex.setOutMessage(msg);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ReflectionServiceFactoryBean method initializeWSDLOperations.
protected void initializeWSDLOperations() {
List<OperationInfo> removes = new ArrayList<>();
Method[] methods = serviceClass.getMethods();
Arrays.sort(methods, new MethodComparator());
InterfaceInfo intf = getInterfaceInfo();
Map<QName, Method> validMethods = new HashMap<>();
for (Method m : methods) {
if (isValidMethod(m)) {
QName opName = getOperationName(intf, m);
validMethods.put(opName, m);
}
}
for (OperationInfo o : intf.getOperations()) {
Method selected = null;
for (Map.Entry<QName, Method> m : validMethods.entrySet()) {
QName opName = m.getKey();
if (o.getName().getNamespaceURI().equals(opName.getNamespaceURI()) && isMatchOperation(o.getName().getLocalPart(), opName.getLocalPart())) {
selected = m.getValue();
break;
}
}
if (selected == null) {
LOG.log(Level.WARNING, "NO_METHOD_FOR_OP", o.getName());
removes.add(o);
} else {
initializeWSDLOperation(intf, o, selected);
}
}
for (OperationInfo op : removes) {
intf.removeOperation(op);
}
// Update the bindings.
for (ServiceInfo service : getService().getServiceInfos()) {
for (BindingInfo bi : service.getBindings()) {
List<BindingOperationInfo> biremoves = new ArrayList<>();
for (BindingOperationInfo binfo : bi.getOperations()) {
if (removes.contains(binfo.getOperationInfo())) {
biremoves.add(binfo);
} else {
binfo.updateUnwrappedOperation();
}
}
for (BindingOperationInfo binfo : biremoves) {
bi.removeOperation(binfo);
}
}
}
sendEvent(Event.INTERFACE_CREATED, intf, getServiceClass());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class WSDLServiceBuilder method buildServices.
private List<ServiceInfo> buildServices(Definition def, Service serv, QName endpointName, DescriptionInfo d) {
Map<QName, ServiceInfo> services = new LinkedHashMap<>();
DescriptionInfo description = d;
if (null == description) {
description = new DescriptionInfo();
if (recordOriginal) {
description.setProperty(WSDL_DEFINITION, def);
}
description.setName(def.getQName());
description.setBaseURI(def.getDocumentBaseURI());
copyExtensors(description, def.getExtensibilityElements());
copyExtensionAttributes(description, def);
Set<Definition> done = new HashSet<>();
done.add(def);
Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
for (List<Import> imports : values) {
for (Import imp : imports) {
if (!done.contains(imp.getDefinition())) {
done.add(imp.getDefinition());
copyExtensors(description, imp.getExtensibilityElements());
copyExtensionAttributes(description, imp);
copyExtensors(description, imp.getDefinition().getExtensibilityElements());
copyExtensionAttributes(description, imp.getDefinition());
}
}
}
}
for (Port port : cast(serv.getPorts().values(), Port.class)) {
if (endpointName != null && !endpointName.getLocalPart().equals(port.getName())) {
continue;
}
Binding binding = port.getBinding();
PortType bindingPt = binding.getPortType();
if (bindingPt == null) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_MISSING_TYPE", LOG, binding.getQName());
throw new WSDLRuntimeException(msg);
}
// TODO: wsdl4j's bug. if there is recursive import,
// wsdl4j can not get operation input message
PortType pt = def.getPortType(bindingPt.getQName());
if (pt == null) {
pt = bindingPt;
}
ServiceInfo service = services.get(pt.getQName());
if (service == null) {
service = new ServiceInfo();
service.setDescription(description);
description.getDescribed().add(service);
if (recordOriginal) {
service.setProperty(WSDL_DEFINITION, def);
service.setProperty(WSDL_SERVICE, serv);
}
getSchemas(def, service);
copyDocumentation(service, serv);
service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
service.setTargetNamespace(def.getTargetNamespace());
service.setName(serv.getQName());
copyExtensors(service, serv.getExtensibilityElements());
copyExtensionAttributes(service, serv);
buildInterface(service, pt);
services.put(pt.getQName(), service);
}
BindingInfo bi = service.getBinding(binding.getQName());
if (bi == null) {
bi = buildBinding(service, binding);
}
buildEndpoint(service, bi, port);
}
return new ArrayList<>(services.values());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class SimpleBatchSTSClient method findOperation.
protected BindingOperationInfo findOperation(String suffix) {
BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
for (BindingOperationInfo boi : bi.getOperations()) {
SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
if (soi != null && soi.getAction() != null && soi.getAction().endsWith(suffix)) {
PolicyEngine pe = bus.getExtension(PolicyEngine.class);
Conduit conduit = client.getConduit();
EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint().getEndpointInfo(), boi, conduit, PhaseInterceptorChain.getCurrentMessage());
setPolicyInternal(effectivePolicy.getPolicy());
return boi;
}
}
// we can at least find it by name and then set the action and such manually later.
for (BindingOperationInfo boi : bi.getOperations()) {
if (boi.getInput().getMessageInfo().getMessageParts().size() > 0) {
MessagePartInfo mpi = boi.getInput().getMessageInfo().getMessagePart(0);
if ("RequestSecurityToken".equals(mpi.getConcreteName().getLocalPart())) {
return boi;
}
}
}
return null;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class JaxwsServiceBuilderTest method testCXF669.
@Test
public void testCXF669() throws Exception {
boolean oldSetting = generator.allowImports();
generator.setAllowImports(true);
builder.setServiceClass(org.apache.cxf.tools.fortest.cxf669.HelloImpl.class);
ServiceInfo service = builder.createService();
assertNotNull(service);
assertEquals(new QName("http://foo.com/HelloWorldService", "HelloService"), service.getName());
assertEquals(new QName("http://foo.com/HelloWorld", "HelloWorld"), service.getInterface().getName());
assertEquals(1, service.getSchemas().size());
assertEquals("http://foo.com/HelloWorld", service.getSchemas().iterator().next().getNamespaceURI());
Collection<BindingInfo> bindings = service.getBindings();
assertEquals(1, bindings.size());
assertEquals(new QName("http://foo.com/HelloWorldService", "HelloServiceSoapBinding"), bindings.iterator().next().getName());
generator.setServiceModel(service);
File wsdl = getOutputFile("HelloService.wsdl");
assertNotNull(wsdl);
generator.generate(wsdl);
assertTrue(wsdl.exists());
File logical = new File(output, "HelloWorld.wsdl");
assertTrue(logical.exists());
File schema = new File(output, "HelloService_schema1.xsd");
assertTrue(schema.exists());
String s = new String(Files.readAllBytes(wsdl.toPath()));
assertTrue(s.indexOf("<wsdl:import namespace=\"http://foo.com/HelloWorld\" " + "location=\"HelloWorld.wsdl\">") != -1);
assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorldService\"") != -1);
s = new String(Files.readAllBytes(logical.toPath()));
assertTrue(s.indexOf("<import namespace=\"http://foo.com/HelloWorld\"") != -1);
assertTrue(s.indexOf("schemaLocation=\"HelloService_schema1.xsd\"/>") != -1);
assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1);
s = new String(Files.readAllBytes(schema.toPath()));
assertTrue(s.indexOf("targetNamespace=\"http://foo.com/HelloWorld\"") != -1);
generator.setAllowImports(oldSetting);
}
Aggregations