use of org.apache.cxf.jaxb.JAXBDataBinding in project components by Talend.
the class NetSuiteClientService method setPreferences.
/**
* Set preferences for given port.
*
* @param port port which to set preferences for
* @param nsPreferences general preferences
* @param nsSearchPreferences search preferences
* @throws NetSuiteException if an error occurs during performing of operation
*/
protected void setPreferences(PortT port, NsPreferences nsPreferences, NsSearchPreferences nsSearchPreferences) throws NetSuiteException {
Object searchPreferences = createNativeSearchPreferences(nsSearchPreferences);
Object preferences = createNativePreferences(nsPreferences);
try {
Header searchPreferencesHeader = new Header(new QName(getPlatformMessageNamespaceUri(), "searchPreferences"), searchPreferences, new JAXBDataBinding(searchPreferences.getClass()));
Header preferencesHeader = new Header(new QName(getPlatformMessageNamespaceUri(), "preferences"), preferences, new JAXBDataBinding(preferences.getClass()));
setHeader(port, preferencesHeader);
setHeader(port, searchPreferencesHeader);
} catch (JAXBException e) {
throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR), "XML binding error", e);
}
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class RPCInInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
ServiceInfo si = getMockedServiceModel(this.getClass().getResource("/wsdl_soap/hello_world_rpc_lit.wsdl").toString());
BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
boi.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
boi.getOperationInfo().getInput().getMessagePartByIndex(0).setIndex(1);
boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
soapMessage.getExchange().put(BindingOperationInfo.class, boi);
control.reset();
Service service = control.createMock(Service.class);
JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
service.getDataBinding();
EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
service.getServiceInfos();
List<ServiceInfo> list = Arrays.asList(si);
EasyMock.expectLastCall().andReturn(list).anyTimes();
EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
soapMessage.getExchange().put(Service.class, service);
soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
control.replay();
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class RPCOutInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
ServiceInfo si = getMockedServiceModel(this.getClass().getResource("/wsdl_soap/hello_world_rpc_lit.wsdl").toString());
BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
soapMessage.getExchange().put(BindingOperationInfo.class, boi);
control.reset();
Service service = control.createMock(Service.class);
EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
service.getDataBinding();
EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
service.getServiceInfos();
List<ServiceInfo> list = Arrays.asList(si);
EasyMock.expectLastCall().andReturn(list).anyTimes();
soapMessage.getExchange().put(Service.class, service);
soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
control.replay();
MyComplexStruct mcs = new MyComplexStruct();
mcs.setElem1("elem1");
mcs.setElem2("elem2");
mcs.setElem3(45);
MessageContentsList param = new MessageContentsList();
param.add(mcs);
soapMessage.setContent(List.class, param);
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class XMLStreamDataWriterTest method testWriteRPCLit1.
@Test
public void testWriteRPCLit1() throws Exception {
JAXBDataBinding db = getTestWriterFactory();
DataWriter<XMLStreamWriter> dw = db.createWriter(XMLStreamWriter.class);
assertNotNull(dw);
String val = new String("TESTOUTPUTMESSAGE");
QName elName = new QName("http://apache.org/hello_world_rpclit/types", "in");
MessagePartInfo part = new MessagePartInfo(elName, null);
part.setElement(true);
part.setElementQName(elName);
dw.write(val, part, streamWriter);
streamWriter.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLStreamReader xr = inFactory.createXMLStreamReader(bais);
DepthXMLStreamReader reader = new DepthXMLStreamReader(xr);
StaxUtils.toNextElement(reader);
assertEquals(new QName("http://apache.org/hello_world_rpclit/types", "in"), reader.getName());
StaxUtils.nextEvent(reader);
StaxUtils.toNextText(reader);
assertEquals("TESTOUTPUTMESSAGE", reader.getText());
}
use of org.apache.cxf.jaxb.JAXBDataBinding in project cxf by apache.
the class XMLStreamDataWriterTest method testWriteWithContextualNamespaceDecls.
@Test
public void testWriteWithContextualNamespaceDecls() throws Exception {
JAXBDataBinding db = getTestWriterFactory(GreetMe.class);
Map<String, String> nspref = new HashMap<>();
nspref.put("http://apache.org/hello_world_soap_http/types", "x");
db.setNamespaceMap(nspref);
db.setContextualNamespaceMap(nspref);
// use the output stream instead of XMLStreamWriter to test
DataWriter<OutputStream> dw = db.createWriter(OutputStream.class);
assertNotNull(dw);
GreetMe val = new GreetMe();
val.setRequestType("Hello");
dw.write(val, baos);
String xstr = new String(baos.toByteArray());
// there should be no namespace decls
if (!db.getContext().getClass().getName().contains("eclipse")) {
// bug in eclipse moxy
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=421463
assertEquals("<x:greetMe><x:requestType>Hello</x:requestType></x:greetMe>", xstr);
}
}
Aggregations