本文整理汇总了Java中org.apache.cxf.jaxb.JAXBDataBinding类的典型用法代码示例。如果您正苦于以下问题:Java JAXBDataBinding类的具体用法?Java JAXBDataBinding怎么用?Java JAXBDataBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JAXBDataBinding类属于org.apache.cxf.jaxb包,在下文中一共展示了JAXBDataBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildOutOfBandHeaderList
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
protected static List<Header> buildOutOfBandHeaderList(boolean invalid) throws JAXBException {
OutofBandHeader ob = new OutofBandHeader();
ob.setName("testOobHeader");
ob.setValue("testOobHeaderValue");
ob.setHdrAttribute(invalid ? "dontProcess" : "testHdrAttribute");
SoapHeader hdr = new SoapHeader(
new QName(Constants.TEST_HDR_NS, Constants.TEST_HDR_REQUEST_ELEM),
ob,
new JAXBDataBinding(ob.getClass()));
hdr.setMustUnderstand(invalid);
List<Header> headers = new ArrayList<Header>();
headers.add(hdr);
return headers;
}
示例2: addReplyOutOfBandHeader
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
private void addReplyOutOfBandHeader() {
if (context != null) {
MessageContext ctx = context.getMessageContext();
if (ctx != null) {
try {
OutofBandHeader ob = new OutofBandHeader();
ob.setName("testOobReturnHeaderName");
ob.setValue("testOobReturnHeaderValue");
ob.setHdrAttribute("testReturnHdrAttribute");
JAXBElement<OutofBandHeader> job = new JAXBElement<OutofBandHeader>(
new QName(Constants.TEST_HDR_NS, Constants.TEST_HDR_RESPONSE_ELEM),
OutofBandHeader.class, null, ob);
Header hdr = new Header(
new QName(Constants.TEST_HDR_NS, Constants.TEST_HDR_RESPONSE_ELEM),
job,
new JAXBDataBinding(ob.getClass()));
List<Header> hdrList = CastUtils.cast((List<?>) ctx.get(Header.HEADER_LIST));
hdrList.add(hdr);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
示例3: createRouteBuilder
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
// START SNIPPET: payload_soap_header_set
from("direct:start").process(new Processor() {
public void process(Exchange exchange) throws Exception {
CallerIDHeaderType callerId = new CallerIDHeaderType();
callerId.setName("Willem");
callerId.setPhoneNumber("108");
SoapHeader soapHeader = new SoapHeader(new QName("http://camel.apache.org/pizza/types", "CallerIDHeader"),
callerId, new JAXBDataBinding(CallerIDHeaderType.class));
List<SoapHeader> soapHeaders = new ArrayList<SoapHeader>(1);
soapHeaders.add(soapHeader);
// sets the SOAP header via a camel header
exchange.getIn().setHeader(Header.HEADER_LIST, soapHeaders);
}
}).to(getServiceEndpointURI()) //
.to("mock:end");
// END SNIPPET: payload_soap_header_set
}
};
}
示例4: setPreferences
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
/**
* 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);
}
}
示例5: setLoginHeaders
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
/**
* Set log-in specific SOAP headers for given port.
*
* @param port port
* @throws NetSuiteException if an error occurs during performing of operation
*/
protected void setLoginHeaders(PortT port) throws NetSuiteException {
if (!StringUtils.isEmpty(credentials.getApplicationId())) {
Object applicationInfo = createNativeApplicationInfo(credentials);
try {
if (applicationInfo != null) {
Header appInfoHeader = new Header(
new QName(getPlatformMessageNamespaceUri(), "applicationInfo"),
applicationInfo, new JAXBDataBinding(applicationInfo.getClass()));
setHeader(port, appInfoHeader);
}
} catch (JAXBException e) {
throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR),
"XML binding error", e);
}
}
}
示例6: newToken
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
@Override
public void newToken(String token) {
if (useSoapHeaderSessions) {
for (PublicInterface p : getServiceInterfaces().values()) {
List<Header> headers = new ArrayList<Header>();
try {
Token tokenObject = new Token(token);
Header sessionHeader = new Header(new QName("uri:org.bimserver.shared", "token"), tokenObject, new JAXBDataBinding(Token.class));
headers.add(sessionHeader);
} catch (JAXBException e) {
LOGGER.error("", e);
}
((BindingProvider) p).getRequestContext().put(Header.HEADER_LIST, headers);
}
}
}
示例7: configureBindingCustomization
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected static void configureBindingCustomization(DataBinding db, BindingCustomization customization)
{
//JAXB
if (customization instanceof JAXBBindingCustomization)
{
if (db != null && db instanceof JAXBDataBinding)
{
((JAXBDataBinding)db).setContextProperties(customization);
}
}
//add other binding customizations here below
}
示例8: getResourceUriHeader
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
private Header getResourceUriHeader() {
AttributableURI uri = new AttributableURI();
uri.setValue(m_resourceUri);
JAXBElement<AttributableURI> resourceURI = factory.createResourceURI(uri);
try {
return new Header(resourceURI.getName(), resourceURI, new JAXBDataBinding(AttributableURI.class));
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
示例9: getSelectorSetHeader
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
private Header getSelectorSetHeader() {
SelectorSetType selectorSetType = factory.createSelectorSetType();
for (Entry<String, String> selectorEntry : m_selectors.entrySet()) {
SelectorType selector = factory.createSelectorType();
selector.setName(selectorEntry.getKey());
selector.getContent().add(selectorEntry.getValue());
selectorSetType.getSelector().add(selector);
}
JAXBElement<SelectorSetType> el = factory.createSelectorSet(selectorSetType);
try {
return new Header(el.getName(), el, new JAXBDataBinding(el.getValue().getClass()));
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
示例10: setUserAgentPropietaryApacheCXF
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
/**
* See Apache CXF explanation for adding headers:
* http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest/response?
*/
protected void setUserAgentPropietaryApacheCXF() {
try {
List<Header> headers = new ArrayList<>();
Header userAgentHeader = new Header(new QName("uri:com.movilizer.mds.webservice",
"user-agent"), userAgent, new JAXBDataBinding(String.class));
headers.add(userAgentHeader);
((BindingProvider) movilizerCloud).getRequestContext().put(Header.HEADER_LIST, headers);
} catch (JAXBException e) {
if (logger.isErrorEnabled()) {
logger.error(String.format(MESSAGES.MARSHALLING_ERROR, userAgent), e);
}
}
}
示例11: addSoapHeader
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
private void addSoapHeader(Map<String, String> filteredParams, SoapMessage soapMessage) {
try {
final Header tpicHeader = new Header(TraceeConstants.SOAP_HEADER_QNAME, TpicMap.wrap(filteredParams),
new JAXBDataBinding(TpicMap.class));
soapMessage.getHeaders().add(tpicHeader);
} catch (JAXBException e) {
LOGGER.warn("Error occured during TracEE soap header creation: {}", e.getMessage());
LOGGER.debug("Detailed exception", e);
}
}
示例12: shouldHandleMessageWithoutTraceeHeader
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
@Test
public void shouldHandleMessageWithoutTraceeHeader() throws JAXBException {
final Map<String, String> contextMap = new HashMap<>();
contextMap.put("mySoapKey", "mySoapContextValue");
soapMessage.getHeaders().add(new Header(new QName(TraceeConstants.SOAP_HEADER_NAMESPACE, "SOME_OTHER"), contextMap, new JAXBDataBinding(HashMap.class)));
inInterceptor.handleMessage(soapMessage);
assertThat(backend.copyToMap(), not(hasKey("mySoapKey")));
when(soapMessage.getExchange()).thenReturn(mock(Exchange.class));
}
示例13: getServiceBuilder
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ServiceBuilder getServiceBuilder(Class<?> clazz) throws ToolException {
JaxwsServiceBuilder builder = new JaxwsServiceBuilder();
JAXBDataBinding dataBinding = new JAXBDataBinding();
dataBinding.setExtraClass(JaxbUtils.findExtraClasses(clazz));
builder.setDataBinding(dataBinding);
builder.setServiceClass(clazz);
builder.validate();
String soapNS = getSoapNS(clazz);
builder.setTransportId(soapNS);
builder.setBus(getBus());
builder.setBindingId(soapNS);
return builder;
}
示例14: makeDelegationIdHeader
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
private List<Header> makeDelegationIdHeader(EndpointReferenceType epr) throws JAXBException {
List<Header> headers = new ArrayList<Header>();
Header delegationIdHeader = new Header(new QName("http://cds.gaards.cagrid.org/CredentialDelegationService/DelegatedCredential",
"DelegatedCredentialKey"), epr, new JAXBDataBinding(EndpointReferenceType.class));
headers.add(delegationIdHeader);
return headers;
}
示例15: getUsername
import org.apache.cxf.jaxb.JAXBDataBinding; //导入依赖的package包/类
private String getUsername() {
MessageContext messageContext = context.getMessageContext();
if (messageContext == null || !(messageContext instanceof WrappedMessageContext)) {
LOG.error("Message context is null or not an instance of WrappedMessageContext.");
return null;
}
Message message = ((WrappedMessageContext) messageContext).getWrappedMessage();
List<Header> headers = CastUtils.cast((List<?>) message.get(Header.HEADER_LIST));
if (headers != null) {
for (Header h : headers) {
Object o = h.getObject();
// Unwrap the node using JAXB
if (o instanceof Node) {
JAXBContext jaxbContext;
try {
// TODO: Check performance
jaxbContext = new JAXBDataBinding(Credentials.class).getContext();
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
o = unmarshaller.unmarshal((Node) o);
} catch (JAXBException e) {
// failed to get the credentials object from the headers
LOG.error("JAXB error trying to unwrap credentials", e);
}
}
if (o instanceof Credentials) {
Credentials c = (Credentials) o;
// Note: We're using the username as session ID.
String username = c.getSessionId();
if (username == null) {
LOG.debug("No session id in credentials object, get from login");
username = c.getLogin().getUsername();
}
return username;
} else {
LOG.error("No credentials object");
}
}
} else {
LOG.error("No headers found");
}
return null;
}