use of com.sun.xml.ws.spi.db.BindingContext in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method generateSOAPMessages.
/**
* Generates messages for a SOAPBinding
* @param method The {@link JavaMethod} to generate messages for
* @param binding The {@link com.sun.xml.ws.api.model.soap.SOAPBinding} to add the generated messages to
*/
protected void generateSOAPMessages(JavaMethodImpl method, com.sun.xml.ws.api.model.soap.SOAPBinding binding) {
boolean isDoclit = binding.isDocLit();
// Message message = portDefinitions.message().name(method.getOperation().getName().getLocalPart());
Message message = portDefinitions.message().name(method.getRequestMessageName());
extension.addInputMessageExtension(message, method);
com.sun.xml.ws.wsdl.writer.document.Part part;
BindingContext jaxbContext = model.getBindingContext();
boolean unwrappable = true;
for (ParameterImpl param : method.getRequestParameters()) {
if (isDoclit) {
if (isHeaderParameter(param))
unwrappable = false;
part = message.part().name(param.getPartName());
part.element(param.getName());
} else {
if (param.isWrapperStyle()) {
for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
part = message.part().name(childParam.getPartName());
part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
}
} else {
part = message.part().name(param.getPartName());
part.element(param.getName());
}
}
}
if (method.getMEP() != MEP.ONE_WAY) {
message = portDefinitions.message().name(method.getResponseMessageName());
extension.addOutputMessageExtension(message, method);
for (ParameterImpl param : method.getResponseParameters()) {
if (isDoclit) {
part = message.part().name(param.getPartName());
part.element(param.getName());
} else {
if (param.isWrapperStyle()) {
for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
part = message.part().name(childParam.getPartName());
part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
}
} else {
part = message.part().name(param.getPartName());
part.element(param.getName());
}
}
}
}
for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
QName tagName = exception.getDetailType().tagName;
String messageName = exception.getMessageName();
QName messageQName = new QName(model.getTargetNamespace(), messageName);
if (processedExceptions.contains(messageQName))
continue;
message = portDefinitions.message().name(messageName);
extension.addFaultMessageExtension(message, method, exception);
// tagName.getLocalPart());
part = message.part().name("fault");
part.element(tagName);
processedExceptions.add(messageQName);
}
}
use of com.sun.xml.ws.spi.db.BindingContext in project metro-jax-ws by eclipse-ee4j.
the class AbstractSEIModelImpl method createJAXBContext.
private void createJAXBContext() {
final List<TypeInfo> types = getAllTypeInfos();
final List<Class> cls = new ArrayList<>(types.size() + additionalClasses.size());
cls.addAll(additionalClasses);
for (TypeInfo type : types) {
cls.add((Class) type.type);
}
try {
// jaxbContext = JAXBRIContext.newInstance(cls, types, targetNamespace, false);
// Need to avoid doPriv block once JAXB is fixed. Afterwards, use the above
bindingContext = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
@Override
public BindingContext run() throws Exception {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "Creating JAXBContext with classes={0} and types={1}", new Object[] { cls, types });
}
UsesJAXBContextFeature f = features.get(UsesJAXBContextFeature.class);
com.oracle.webservices.api.databinding.DatabindingModeFeature dmf = features.get(com.oracle.webservices.api.databinding.DatabindingModeFeature.class);
JAXBContextFactory factory = f != null ? f.getFactory() : null;
if (factory == null)
factory = JAXBContextFactory.DEFAULT;
// return factory.createJAXBContext(AbstractSEIModelImpl.this,cls,types);
databindingInfo.properties().put(JAXBContextFactory.class.getName(), factory);
if (dmf != null) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.log(Level.FINE, "DatabindingModeFeature in SEI specifies mode: {0}", dmf.getMode());
databindingInfo.setDatabindingMode(dmf.getMode());
}
if (f != null)
databindingInfo.setDatabindingMode(BindingContextFactory.DefaultDatabindingMode);
databindingInfo.setClassLoader(classLoader);
databindingInfo.contentClasses().addAll(cls);
databindingInfo.typeInfos().addAll(types);
databindingInfo.properties().put("c14nSupport", Boolean.FALSE);
databindingInfo.setDefaultNamespace(AbstractSEIModelImpl.this.getDefaultSchemaNamespace());
BindingContext bc = BindingContextFactory.create(databindingInfo);
if (LOGGER.isLoggable(Level.FINE))
LOGGER.log(Level.FINE, "Created binding context: {0}", bc.getClass().getName());
// System.out.println("---------------------- databinding " + bc);
return bc;
}
});
// createBridgeMap(types);
createBondMap(types);
} catch (PrivilegedActionException e) {
throw new WebServiceException(ModelerMessages.UNABLE_TO_CREATE_JAXB_CONTEXT(), e);
}
knownNamespaceURIs = new ArrayList<>();
for (String namespace : bindingContext.getKnownNamespaceURIs()) {
if (namespace.length() > 0) {
if (!namespace.equals(SOAPNamespaceConstants.XSD) && !namespace.equals(SOAPNamespaceConstants.XMLNS))
knownNamespaceURIs.add(namespace);
}
}
marshallers = new Pool.Marshaller(jaxbContext);
// return getJAXBContext();
}
Aggregations