use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class JAXBDataBindingTest method setUp.
@Before
public void setUp() throws Exception {
jaxbDataBinding = new JAXBDataBinding();
String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
LOG.info("the path of wsdl file is " + wsdlUrl);
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
def = wsdlReader.readWSDL(wsdlUrl);
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(destinationFactoryManager);
control.replay();
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
if (serv != null) {
service = serv;
break;
}
}
wsdlServiceBuilder.buildServices(def, service);
}
use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class TestBase method setUp.
@Before
public void setUp() throws Exception {
bus = BusFactory.newInstance().createBus();
BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
IMocksControl control = createNiceControl();
BindingFactory bf = control.createMock(BindingFactory.class);
Binding binding = control.createMock(Binding.class);
expect(bf.createBinding(null)).andStubReturn(binding);
expect(binding.getInFaultInterceptors()).andStubReturn(new ArrayList<Interceptor<? extends Message>>());
expect(binding.getOutFaultInterceptors()).andStubReturn(new ArrayList<Interceptor<? extends Message>>());
bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);
String ns = "http://apache.org/hello_world_soap_http";
WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource("/org/apache/cxf/jaxb/resources/wsdl/hello_world.wsdl").toString(), new QName(ns, "SOAPService"));
service = factory.create();
endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
endpoint = new EndpointImpl(bus, service, endpointInfo);
JAXBDataBinding db = new JAXBDataBinding();
db.setContext(JAXBContext.newInstance(new Class[] { GreetMe.class, GreetMeResponse.class }));
service.setDataBinding(db);
operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
operation.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);
message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
exchange.put(Service.class, service);
exchange.put(Endpoint.class, endpoint);
exchange.put(Binding.class, endpoint.getBinding());
}
use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class AbstractWSDLBasedEndpointFactory method createEndpoint.
protected Endpoint createEndpoint() throws BusException, EndpointException {
serviceFactory.setFeatures(getFeatures());
if (serviceName != null) {
serviceFactory.setServiceName(serviceName);
}
if (endpointName != null) {
serviceFactory.setEndpointName(endpointName);
}
Service service = serviceFactory.getService();
if (service == null) {
initializeServiceFactory();
service = serviceFactory.create();
}
if (endpointName == null) {
endpointName = serviceFactory.getEndpointName();
}
EndpointInfo ei = service.getEndpointInfo(endpointName);
if (ei != null) {
if ((transportId != null && !ei.getTransportId().equals(transportId)) || (bindingId != null && !ei.getBinding().getBindingId().equals(bindingId))) {
ei = null;
} else {
BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
bindingFactory = bfm.getBindingFactory(ei.getBinding().getBindingId());
}
}
if (ei == null) {
if (getAddress() == null) {
ei = ServiceModelUtil.findBestEndpointInfo(serviceFactory.getInterfaceName(), service.getServiceInfos());
}
if (ei == null && !serviceFactory.isPopulateFromClass()) {
ei = ServiceModelUtil.findBestEndpointInfo(serviceFactory.getInterfaceName(), service.getServiceInfos());
if (ei != null) {
BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
bindingFactory = bfm.getBindingFactory(ei.getBinding().getBindingId());
}
if (ei == null) {
LOG.warning("Could not find endpoint/port for " + endpointName + " in wsdl. Creating default.");
} else if (!ei.getName().equals(endpointName)) {
LOG.warning("Could not find endpoint/port for " + endpointName + " in wsdl. Using " + ei.getName() + ".");
}
}
if (ei == null) {
ei = createEndpointInfo(null);
} else if (transportId != null && !ei.getTransportId().equals(transportId)) {
LOG.warning("Transport for endpoint/port " + endpointName + " in wsdl doesn't match " + transportId + ".");
BindingInfo bi = ei.getBinding();
ei = createEndpointInfo(bi);
} else if (bindingId != null && !ei.getBinding().getBindingId().equals(bindingId) && // consider SoapBinding has multiple default namespace
!(SoapBindingFactory.DEFAULT_NAMESPACES.contains(bindingId) && SoapBindingFactory.DEFAULT_NAMESPACES.contains(ei.getBinding().getBindingId()))) {
LOG.warning("Binding for endpoint/port " + endpointName + " in wsdl doesn't match " + bindingId + ".");
ei = createEndpointInfo(null);
} else if (getAddress() != null) {
ei.setAddress(getAddress());
if (ei.getAddress().startsWith("camel") || ei.getAddress().startsWith("local")) {
modifyTransportIdPerAddress(ei);
}
}
} else if (getAddress() != null) {
ei.setAddress(getAddress());
}
if (publishedEndpointUrl != null && !"".equals(publishedEndpointUrl)) {
ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
}
if (endpointReference != null) {
ei.setAddress(endpointReference);
}
Endpoint ep = service.getEndpoints().get(ei.getName());
if (ep == null) {
ep = serviceFactory.createEndpoint(ei);
((EndpointImpl) ep).initializeActiveFeatures(getFeatures());
} else {
serviceFactory.setEndpointName(ei.getName());
if (ep.getActiveFeatures() == null) {
((EndpointImpl) ep).initializeActiveFeatures(getFeatures());
}
}
if (properties != null) {
ep.putAll(properties);
}
service.getEndpoints().put(ep.getEndpointInfo().getName(), ep);
if (getInInterceptors() != null) {
ep.getInInterceptors().addAll(getInInterceptors());
ep.getInInterceptors().add(WSDLGetInterceptor.INSTANCE);
}
if (getOutInterceptors() != null) {
ep.getOutInterceptors().addAll(getOutInterceptors());
}
if (getInFaultInterceptors() != null) {
ep.getInFaultInterceptors().addAll(getInFaultInterceptors());
}
if (getOutFaultInterceptors() != null) {
ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINT_SELECTED, ei, ep, serviceFactory.getServiceClass(), getServiceClass());
return ep;
}
use of org.apache.cxf.binding.BindingFactoryManager in project cxf by apache.
the class JaxWsServiceConfigurationTest method getMockedServiceModel.
private ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
Definition def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
IMocksControl control = EasyMock.createNiceControl();
Bus bus = control.createMock(Bus.class);
BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
Service service = null;
for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
Object obj = it.next();
if (obj instanceof Service) {
service = (Service) obj;
break;
}
}
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
return serviceInfo;
}
use of org.apache.cxf.binding.BindingFactoryManager 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);
}
Aggregations