use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ClientFactoryBeanTest method testClientFactoryBean.
@Test
public void testClientFactoryBean() throws Exception {
ClientFactoryBean cfBean = new ClientFactoryBean();
cfBean.setAddress("http://localhost/Hello");
cfBean.setBus(getBus());
cfBean.setServiceClass(HelloService.class);
Client client = cfBean.create();
assertNotNull(client);
Service service = client.getEndpoint().getService();
Map<QName, Endpoint> eps = service.getEndpoints();
assertEquals(1, eps.size());
Endpoint ep = eps.values().iterator().next();
EndpointInfo endpointInfo = ep.getEndpointInfo();
BindingInfo b = endpointInfo.getService().getBindings().iterator().next();
assertTrue(b instanceof SoapBindingInfo);
SoapBindingInfo sb = (SoapBindingInfo) b;
assertEquals("HelloServiceSoapBinding", b.getName().getLocalPart());
assertEquals("document", sb.getStyle());
assertEquals(4, b.getOperations().size());
BindingOperationInfo bop = b.getOperations().iterator().next();
SoapOperationInfo sop = bop.getExtensor(SoapOperationInfo.class);
assertNotNull(sop);
assertEquals("", sop.getAction());
assertEquals("document", sop.getStyle());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class CorbaDestinationTest method testDestination.
@Test
public void testDestination() throws Exception {
endpointInfo = testUtils.setupServiceInfo("http://cxf.apache.org/bindings/corba/simple", "/wsdl_corbabinding/simpleIdl.wsdl", "SimpleCORBAService", "SimpleCORBAPort");
CorbaDestination destination = new CorbaDestination(endpointInfo, orbConfig);
EndpointReferenceType rtype = destination.getAddress();
assertNotNull("EndpointReferenceType should not be null", rtype);
BindingInfo bindingInfo = destination.getBindingInfo();
assertNotNull("BindingInfo should not be null", bindingInfo);
EndpointInfo e2 = destination.getEndPointInfo();
assertNotNull("EndpointInfo should not be null", e2);
Message m = new MessageImpl();
CorbaServerConduit serverConduit = (CorbaServerConduit) destination.getBackChannel(m);
assertNotNull("CorbaServerConduit should not be null", serverConduit);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class Proxy method invoke.
Object invoke(OperationInfo oi, ProtocolVariation protocol, Object[] params, Map<String, Object> context, Exchange exchange, Level exceptionLevel) throws RMException {
if (LOG.isLoggable(Level.INFO)) {
LOG.log(Level.INFO, "Sending out-of-band RM protocol message {0}.", oi == null ? null : oi.getName());
}
RMManager manager = reliableEndpoint.getManager();
Bus bus = manager.getBus();
Endpoint endpoint = reliableEndpoint.getEndpoint(protocol);
BindingInfo bi = reliableEndpoint.getBindingInfo(protocol);
Conduit c = reliableEndpoint.getConduit();
final Client client;
if (params.length > 0 && params[0] instanceof DestinationSequence) {
EndpointReferenceType acksTo = ((DestinationSequence) params[0]).getAcksTo();
String acksAddress = acksTo.getAddress().getValue();
AttributedURIType attrURIType = new AttributedURIType();
attrURIType.setValue(acksAddress);
EndpointReferenceType acks = new EndpointReferenceType();
acks.setAddress(attrURIType);
client = createClient(bus, endpoint, protocol, c, acks);
params = new Object[] {};
} else {
EndpointReferenceType replyTo = reliableEndpoint.getReplyTo();
client = createClient(bus, endpoint, protocol, c, replyTo);
}
BindingOperationInfo boi = bi.getOperation(oi);
try {
if (context != null) {
client.getRequestContext().putAll(context);
}
Object[] result = client.invoke(boi, params, context, exchange);
if (result != null && result.length > 0) {
return result[0];
}
} catch (Exception ex) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("SEND_PROTOCOL_MSG_FAILED_EXC", LOG, oi == null ? null : oi.getName());
LOG.log(exceptionLevel, msg.toString(), ex);
throw new RMException(msg, ex);
}
return null;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class STSUtils method createSTSEndpoint.
// CHECKSTYLE:OFF
private static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName, boolean sc) throws BusException, EndpointException {
// CHECKSTYLE:ON
String ns = namespace + "/wsdl";
ServiceInfo si = new ServiceInfo();
QName iName = new QName(ns, sc ? "SecureConversationTokenService" : "SecurityTokenService");
si.setName(iName);
InterfaceInfo ii = new InterfaceInfo(si, iName);
OperationInfo ioi = addIssueOperation(ii, namespace, ns);
OperationInfo coi = addCancelOperation(ii, namespace, ns);
OperationInfo roi = addRenewOperation(ii, namespace, ns);
si.setInterface(ii);
Service service = new ServiceImpl(si);
BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
BindingFactory bindingFactory = bfm.getBindingFactory(soapVersion);
BindingInfo bi = bindingFactory.createBindingInfo(service, soapVersion, null);
si.addBinding(bi);
if (transportId == null) {
ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
ConduitInitiator ci = cim.getConduitInitiatorForUri(location);
transportId = ci.getTransportIds().get(0);
}
EndpointInfo ei = new EndpointInfo(si, transportId);
ei.setBinding(bi);
ei.setName(epName == null ? iName : epName);
ei.setAddress(location);
si.addEndpoint(ei);
if (policy != null) {
ei.addExtensor(policy);
}
BindingOperationInfo boi = bi.getOperation(ioi);
SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT" : "/RST/Issue"));
boi = bi.getOperation(coi);
soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT/Cancel" : "/RST/Cancel"));
boi = bi.getOperation(roi);
soi = boi.getExtensor(SoapOperationInfo.class);
if (soi == null) {
soi = new SoapOperationInfo();
boi.addExtensor(soi);
}
soi.setAction(namespace + (sc ? "/RST/SCT/Renew" : "/RST/Renew"));
service.setDataBinding(new SourceDataBinding());
return new EndpointImpl(bus, service, ei);
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class XMLMessageInInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
if (isGET(message)) {
LOG.fine("XMLMessageInInterceptor skipped in HTTP GET method");
return;
}
Endpoint ep = message.getExchange().getEndpoint();
XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
if (xsr == null) {
return;
}
DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);
if (!StaxUtils.toNextElement(reader)) {
throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT", LOG));
}
Exchange ex = message.getExchange();
QName startQName = reader.getName();
// handling xml fault message
if (startQName.getLocalPart().equals(XMLFault.XML_FAULT_ROOT)) {
message.getInterceptorChain().abort();
if (ep.getInFaultObserver() != null) {
ep.getInFaultObserver().onMessage(message);
return;
}
}
// handling xml normal inbound message
BindingOperationInfo boi = ex.getBindingOperationInfo();
boolean isRequestor = isRequestor(message);
if (boi == null) {
BindingInfo service = ep.getEndpointInfo().getBinding();
boi = getBindingOperationInfo(isRequestor, startQName, service, xsr);
if (boi != null) {
ex.put(BindingOperationInfo.class, boi);
ex.setOneWay(boi.getOperationInfo().isOneWay());
}
} else {
BindingMessageInfo bmi = isRequestor ? boi.getOutput() : boi.getInput();
if (hasRootNode(bmi, startQName)) {
try {
xsr.nextTag();
} catch (XMLStreamException xse) {
throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", LOG));
}
}
}
}
Aggregations