use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class RPCInInterceptor method setMessage.
private void setMessage(Message message, BindingOperationInfo operation) {
Exchange ex = message.getExchange();
ex.put(BindingOperationInfo.class, operation);
ex.setOneWay(operation.getOperationInfo().isOneWay());
// Set standard MessageContext properties required by JAX_WS, but not specific to JAX_WS.
message.put(Message.WSDL_OPERATION, operation.getName());
ServiceInfo si = operation.getBinding().getService();
QName serviceQName = si.getName();
message.put(Message.WSDL_SERVICE, serviceQName);
QName interfaceQName = si.getInterface().getName();
message.put(Message.WSDL_INTERFACE, interfaceQName);
EndpointInfo endpointInfo = ex.getEndpoint().getEndpointInfo();
QName portQName = endpointInfo.getName();
message.put(Message.WSDL_PORT, portQName);
URI wsdlDescription = endpointInfo.getProperty("URI", URI.class);
if (wsdlDescription == null) {
String address = endpointInfo.getAddress();
try {
wsdlDescription = new URI(address + "?wsdl");
} catch (URISyntaxException e) {
// do nothing
}
endpointInfo.setProperty("URI", wsdlDescription);
}
message.put(Message.WSDL_DESCRIPTION, wsdlDescription);
// configure endpoint and operation level schema validation
setOperationSchemaValidation(message);
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class DispatchImpl method addInvokeOperation.
private void addInvokeOperation(QName operationName, boolean oneWay) {
ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();
OperationInfo invokeOpInfo = info.getInterface().getOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME);
OperationInfo opInfo = info.getInterface().addOperation(operationName);
opInfo.setInput(invokeOpInfo.getInputName(), invokeOpInfo.getInput());
if (!oneWay) {
opInfo.setOutput(invokeOpInfo.getOutputName(), invokeOpInfo.getOutput());
}
for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
bind.addOperation(bo);
}
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class ServiceImpl method initializePorts.
private void initializePorts() {
try {
Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
javax.wsdl.Service serv = def.getService(serviceName);
if (serv == null) {
throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
}
Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
for (Port port : wsdlports.values()) {
QName name = new QName(serviceName.getNamespaceURI(), port.getName());
String address = null;
String bindingID = null;
List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
} else if (e instanceof SOAP12Binding) {
bindingID = SOAPBinding.SOAP12HTTP_BINDING;
} else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
}
}
extensions = CastUtils.cast(port.getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapAddress) {
address = ((SoapAddress) e).getLocationURI();
} else if (e instanceof AddressType) {
address = ((AddressType) e).getLocation();
} else if (e instanceof SOAP12Address) {
address = ((SOAP12Address) e).getLocationURI();
} else if (e instanceof SOAPAddress) {
address = ((SOAPAddress) e).getLocationURI();
} else if (e instanceof HTTPAddress) {
address = ((HTTPAddress) e).getLocationURI();
}
}
addPort(name, bindingID, address);
}
} catch (WebServiceException e) {
throw e;
} catch (Throwable e) {
if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, e.getLocalizedMessage(), e);
}
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
Service service = sf.create();
for (ServiceInfo si : service.getServiceInfos()) {
for (EndpointInfo ei : si.getEndpoints()) {
String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
addPort(ei.getName(), bindingID, ei.getAddress());
}
}
}
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class ServiceImpl method createDispatchService.
private AbstractServiceFactoryBean createDispatchService(DataBinding db) {
AbstractServiceFactoryBean serviceFactory;
final Service dispatchService;
if (null != wsdlURL) {
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
dispatchService = sf.create();
dispatchService.setDataBinding(db);
serviceFactory = sf;
} else {
ReflectionServiceFactoryBean sf = new JaxWsServiceFactoryBean();
sf.setBus(bus);
sf.setServiceName(serviceName);
// maybe we can find another way to create service which have no SEI
sf.setServiceClass(DummyImpl.class);
sf.setDataBinding(db);
dispatchService = sf.create();
serviceFactory = sf;
}
configureObject(dispatchService);
for (ServiceInfo si : dispatchService.getServiceInfos()) {
si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
if (null == wsdlURL) {
for (EndpointInfo ei : si.getEndpoints()) {
ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
}
}
for (BindingInfo bind : si.getBindings()) {
for (BindingOperationInfo bop : bind.getOperations()) {
// force to bare, no unwrapping
if (bop.isUnwrappedCapable()) {
bop.getOperationInfo().setUnwrappedOperation(null);
bop.setUnwrappedOperation(null);
}
}
}
}
return serviceFactory;
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class JAXBDataBinding method initialize.
@SuppressWarnings("unchecked")
public synchronized void initialize(Service service) {
inInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
inFaultInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
// context is already set, don't redo it
if (context != null) {
return;
}
contextClasses = new LinkedHashSet<>();
for (ServiceInfo serviceInfo : service.getServiceInfos()) {
JAXBContextInitializer initializer = new JAXBContextInitializer(getBus(), serviceInfo, contextClasses, typeRefs, this.getUnmarshallerProperties());
initializer.walk();
if (serviceInfo.getProperty("extra.class") != null) {
Set<Class<?>> exClasses = serviceInfo.getProperty("extra.class", Set.class);
contextClasses.addAll(exClasses);
}
}
String tns = getNamespaceToUse(service);
final CachedContextAndSchemas cachedContextAndSchemas;
try {
cachedContextAndSchemas = createJAXBContextAndSchemas(contextClasses, tns);
} catch (JAXBException e1) {
throw new ServiceConstructionException(e1);
}
final JAXBContext ctx = cachedContextAndSchemas.getContext();
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "CREATED_JAXB_CONTEXT", new Object[] { ctx, contextClasses });
}
setContext(ctx);
for (ServiceInfo serviceInfo : service.getServiceInfos()) {
SchemaCollection col = serviceInfo.getXmlSchemaCollection();
if (col.getXmlSchemas().length > 1) {
// someone has already filled in the types
justCheckForJAXBAnnotations(serviceInfo);
continue;
}
boolean schemasFromCache = false;
Collection<DOMSource> schemas = getSchemas();
if (schemas == null || schemas.isEmpty()) {
schemas = cachedContextAndSchemas.getSchemas();
if (schemas != null) {
schemasFromCache = true;
}
} else {
schemasFromCache = true;
}
Set<DOMSource> bi = new LinkedHashSet<>();
if (schemas == null) {
schemas = new LinkedHashSet<>();
try {
for (DOMResult r : generateJaxbSchemas()) {
DOMSource src = new DOMSource(r.getNode(), r.getSystemId());
if (isInBuiltInSchemas(r)) {
bi.add(src);
} else {
schemas.add(src);
}
}
// put any builtins at the end. Anything that DOES import them
// will cause it to load automatically and we'll skip them later
schemas.addAll(bi);
} catch (IOException e) {
throw new ServiceConstructionException("SCHEMA_GEN_EXC", LOG, e);
}
}
for (DOMSource r : schemas) {
if (bi.contains(r)) {
String ns = ((Document) r.getNode()).getDocumentElement().getAttribute("targetNamespace");
if (serviceInfo.getSchema(ns) != null) {
continue;
}
}
// StaxUtils.print(r.getNode());
// System.out.println();
addSchemaDocument(serviceInfo, col, (Document) r.getNode(), r.getSystemId());
}
JAXBSchemaInitializer schemaInit = new JAXBSchemaInitializer(serviceInfo, col, context, this.qualifiedSchemas, tns);
schemaInit.walk();
if (cachedContextAndSchemas != null && !schemasFromCache) {
cachedContextAndSchemas.setSchemas(schemas);
}
}
}
Aggregations