use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class AttributeTest method testDeserialization.
@Test
public void testDeserialization() throws Exception {
setupClientAndRhino("attribute-test-proxy-factory");
testUtilities.readResourceIntoRhino("/attributeTests.js");
DataBinding dataBinding = new JAXBDataBinding(AttributeTestBean.class);
assertNotNull(dataBinding);
AttributeTestBean bean = new AttributeTestBean();
bean.element1 = "e1";
bean.element2 = "e2";
bean.attribute1 = "a1";
bean.attribute2 = "a2";
String serialized = serializeObject(dataBinding, bean);
testUtilities.rhinoCallInContext("deserializeAttributeTestBean", serialized);
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class TestBase method common.
protected void common(String wsdl, QName portName, Class<?>... jaxbClasses) throws Exception {
Bus bus = BusFactory.getDefaultBus();
WSDLManagerImpl manager = new WSDLManagerImpl();
XMLWSDLExtensionLoader loader = new XMLWSDLExtensionLoader(bus);
loader.registerExtensors(manager);
assertNotNull(bus.getExtension(WSDLManager.class));
WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource(wsdl).toString(), new QName(portName.getNamespaceURI(), "XMLService"));
org.apache.cxf.service.Service service = factory.create();
EndpointInfo epi = service.getEndpointInfo(portName);
assertNotNull(epi);
serviceInfo = epi.getService();
JAXBDataBinding db = new JAXBDataBinding();
db.initialize(service);
db.setContext(JAXBContext.newInstance(jaxbClasses));
service.setDataBinding(db);
Endpoint endpoint = new EndpointImpl(bus, service, epi);
xmlMessage.getExchange().put(Endpoint.class, endpoint);
xmlMessage.getExchange().put(org.apache.cxf.service.Service.class, service);
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class SwAOutInterceptor method handleMessage.
public void handleMessage(SoapMessage message) throws Fault {
Exchange ex = message.getExchange();
BindingOperationInfo bop = ex.getBindingOperationInfo();
if (bop == null) {
return;
}
if (bop.isUnwrapped()) {
bop = bop.getWrappedOperation();
}
boolean client = isRequestor(message);
BindingMessageInfo bmi = client ? bop.getInput() : bop.getOutput();
if (bmi == null) {
return;
}
SoapBodyInfo sbi = bmi.getExtensor(SoapBodyInfo.class);
if (sbi == null || sbi.getAttachments() == null || sbi.getAttachments().isEmpty()) {
Service s = ex.getService();
DataBinding db = s.getDataBinding();
if (db instanceof JAXBDataBinding && hasSwaRef((JAXBDataBinding) db)) {
setupAttachmentOutput(message);
}
return;
}
processAttachments(message, sbi);
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class JaxWsServerFactoryBeanTest method testJaxbExtraClass.
@Test
public void testJaxbExtraClass() {
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setBus(getBus());
sf.setAddress("http://localhost:9000/test");
sf.setServiceClass(Hello.class);
sf.setStart(false);
Map<String, Object> props = sf.getProperties();
if (props == null) {
props = new HashMap<>();
}
props.put("jaxb.additionalContextClasses", new Class[] { DescriptionType.class, DisplayNameType.class });
sf.setProperties(props);
Server server = sf.create();
assertNotNull(server);
Class<?>[] extraClass = ((JAXBDataBinding) sf.getServiceFactory().getDataBinding()).getExtraClass();
assertEquals(extraClass.length, 2);
assertEquals(extraClass[0], DescriptionType.class);
assertEquals(extraClass[1], DisplayNameType.class);
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class RMEndpoint method createService.
void createService(ProtocolVariation protocol) {
ServiceInfo si = new ServiceInfo();
si.setProperty(Schema.class.getName(), getSchema());
QName serviceQName = new QName(protocol.getWSRMNamespace(), SERVICE_NAME);
si.setName(serviceQName);
buildInterfaceInfo(si, protocol);
WrappedService service = new WrappedService(applicationEndpoint.getService(), serviceQName, si);
Class<?> create = protocol.getCodec().getCreateSequenceType();
try {
JAXBContext ctx = JAXBContext.newInstance(PackageUtils.getPackageName(create), create.getClassLoader());
service.setDataBinding(new JAXBDataBinding(ctx));
} catch (JAXBException e) {
throw new ServiceConstructionException(e);
}
service.setInvoker(servant);
services.put(protocol, service);
}
Aggregations