本文整理汇总了Java中org.apache.cxf.headers.Header类的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Header类属于org.apache.cxf.headers包,在下文中一共展示了Header类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleMessage
import org.apache.cxf.headers.Header; //导入依赖的package包/类
@SuppressWarnings("nls")
@Override
public void handleMessage(SoapMessage message) throws Fault
{
final UserState us = CurrentUser.getUserState();
XMLStreamWriterCallback obj = new XMLStreamWriterCallback()
{
@Override
public void write(XMLStreamWriter writer) throws Fault, XMLStreamException
{
writer.writeEmptyElement("equella");
writer.writeAttribute("session", us.getSessionID());
writer.writeAttribute("id", us.getUserBean().getUniqueID());
writer.writeAttribute("username", us.getUserBean().getUsername());
}
};
message.getHeaders().add(new Header(new QName("equella"), obj, new StaxDataBinding()));
}
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:TokenHeaderOutInterceptor.java
示例2: handleMessage
import org.apache.cxf.headers.Header; //导入依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
Header header = message.getHeader(new QName("equella"));
if( header != null )
{
Element e = (Element) header.getObject();
PropBagEx equella = new PropBagEx(e);
String token = equella.getNode("token");
if( !Check.isEmpty(token) )
{
HttpServletRequest request = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST);
try
{
userService.loginWithToken(token, userService.getWebAuthenticationDetails(request), true);
}
catch( RuntimeException ex )
{
LOGGER.error("Error initialising session with SOAP header token '" + token + "' for URL "
+ request.getRequestURL().toString());
throw ex;
}
}
}
}
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:TokenHeaderInInterceptor.java
示例3: validateReturnedOutOfBandHeader
import org.apache.cxf.headers.Header; //导入依赖的package包/类
protected static void validateReturnedOutOfBandHeader(Map<String, Object> responseContext, boolean expect) {
OutofBandHeader hdrToTest = null;
List<Header> oobHdr = CastUtils.cast((List<?>)responseContext.get(Header.HEADER_LIST));
if (!expect) {
if (oobHdr == null || (oobHdr != null && oobHdr.size() == 0)) {
return;
}
fail("Should have got *no* out-of-band headers, but some were found");
}
if (oobHdr == null) {
fail("Should have got List of out-of-band headers");
}
assertTrue("HeaderHolder list expected to conain 1 object received " + oobHdr.size(),
oobHdr.size() == 1);
for (Header hdr1 : oobHdr) {
if (hdr1.getObject() instanceof Node) {
try {
JAXBElement<?> job = (JAXBElement<?>)JAXBContext
.newInstance(org.apache.cxf.outofband.header.ObjectFactory.class)
.createUnmarshaller().unmarshal((Node)hdr1.getObject());
hdrToTest = (OutofBandHeader)job.getValue();
} catch (JAXBException ex) {
ex.printStackTrace();
}
}
}
assertNotNull("out-of-band header should not be null", hdrToTest);
assertTrue("Expected out-of-band Header name testOobReturnHeaderName recevied :"
+ hdrToTest.getName(), "testOobReturnHeaderName".equals(hdrToTest.getName()));
assertTrue("Expected out-of-band Header value testOobReturnHeaderValue recevied :"
+ hdrToTest.getValue(), "testOobReturnHeaderValue".equals(hdrToTest.getValue()));
assertTrue("Expected out-of-band Header attribute testReturnHdrAttribute recevied :"
+ hdrToTest.getHdrAttribute(), "testReturnHdrAttribute"
.equals(hdrToTest.getHdrAttribute()));
}
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:CxfMessageHeadersRelayTest.java
示例4: buildOutOfBandHeaderList
import org.apache.cxf.headers.Header; //导入依赖的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;
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CxfMessageHeadersRelayTest.java
示例5: process
import org.apache.cxf.headers.Header; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
List<SoapHeader> soapHeaders = CastUtils.cast((List<?>)exchange.getIn().getHeader(Header.HEADER_LIST));
// Insert a new header
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><outofbandHeader "
+ "xmlns=\"http://cxf.apache.org/outofband/Header\" hdrAttribute=\"testHdrAttribute\" "
+ "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:mustUnderstand=\"1\">"
+ "<name>New_testOobHeader</name><value>New_testOobHeaderValue</value></outofbandHeader>";
SoapHeader newHeader = new SoapHeader(soapHeaders.get(0).getName(),
StaxUtils.read(new StringReader(xml)).getDocumentElement());
// make sure direction is IN since it is a request message.
newHeader.setDirection(Direction.DIRECTION_IN);
//newHeader.setMustUnderstand(false);
soapHeaders.add(newHeader);
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CxfMessageHeadersRelayTest.java
示例6: verifyHeader
import org.apache.cxf.headers.Header; //导入依赖的package包/类
private void verifyHeader(Object hdr, String headerName, String headerValue) {
if (hdr instanceof Header && ((Header) hdr).getObject() instanceof Node) {
Header hdr1 = (Header) hdr;
try {
JAXBElement<?> job =
(JAXBElement<?>)JAXBContext.newInstance(org.apache.cxf.outofband.header.ObjectFactory.class)
.createUnmarshaller()
.unmarshal((Node) hdr1.getObject());
OutofBandHeader ob = (OutofBandHeader) job.getValue();
if (!headerName.equals(ob.getName())) {
throw new RuntimeException("test failed expected name ' + headerName + ' but found '"
+ ob.getName() + "'");
}
if (!headerValue.equals(ob.getValue())) {
throw new RuntimeException("test failed expected name ' + headerValue + ' but found '"
+ ob.getValue() + "'");
}
} catch (JAXBException ex) {
throw new RuntimeException("test failed", ex);
}
} else {
throw new RuntimeException("test failed. Unexpected type " + hdr.getClass());
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:HeaderTesterWithInsertionImpl.java
示例7: addReplyOutOfBandHeader
import org.apache.cxf.headers.Header; //导入依赖的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();
}
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:HeaderTesterImpl.java
示例8: createRouteBuilder
import org.apache.cxf.headers.Header; //导入依赖的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
}
};
}
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:CxfPayLoadSoapHeaderViaCamelHeaderTest.java
示例9: setPreferences
import org.apache.cxf.headers.Header; //导入依赖的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);
}
}
开发者ID:Talend,项目名称:components,代码行数:31,代码来源:NetSuiteClientService.java
示例10: setLoginHeaders
import org.apache.cxf.headers.Header; //导入依赖的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);
}
}
}
开发者ID:Talend,项目名称:components,代码行数:23,代码来源:NetSuiteClientService.java
示例11: getPaymentService
import org.apache.cxf.headers.Header; //导入依赖的package包/类
/**
* Helper method for getting properly configured payment service Object with required header as per specification
* @return iWallet PaymentService port
*/
private PaymentServiceSoap getPaymentService(){
PaymentService iwalletService = null;
PaymentServiceSoap paymentServiceSoap = null;
try {
iwalletService = new PaymentService(new URL(this.wsdl),new QName(this.namespace,this.serviceName));
paymentServiceSoap = iwalletService.getPaymentServiceSoap();
logger.debug("getPaymentService paymentServiceSoap object",paymentServiceSoap);
List<Header> headersList = getHeaderList();
logger.debug("getPaymentService header list",headersList);
((BindingProvider) paymentServiceSoap).getRequestContext().put(Header.HEADER_LIST,headersList);
} catch (MalformedURLException e) {
logger.info("MalformedURLException occurred", e);
}
logger.debug("getPaymentService iWallet Header enabled port", paymentServiceSoap);
return paymentServiceSoap;
}
开发者ID:DreamOval,项目名称:iwallet-java-connector,代码行数:24,代码来源:Integrator.java
示例12: handleMessage
import org.apache.cxf.headers.Header; //导入依赖的package包/类
public void handleMessage(SoapMessage message) throws Fault {
Document doc = DOMUtils.createDocument();
Element SYSTEM_ID = doc.createElementNS(NAMESPACE_URI, ELEMENT_SYSTEM_ID);
SYSTEM_ID.setTextContent(systemId);
Element SYSTEM_PW = doc.createElementNS(NAMESPACE_URI, ELEMENT_SYSTEM_PW);
SYSTEM_PW.setTextContent(systemPw);
Element token = doc.createElementNS(NAMESPACE_URI, ELEMENT_TOKEN);
token.appendChild(SYSTEM_ID);
token.appendChild(SYSTEM_PW);
SoapHeader header = new SoapHeader(new QName(NAMESPACE_URI), token);
List<Header> headers = message.getHeaders();
headers.add(header);
}
开发者ID:brightzheng100,项目名称:learning-spring-cxf,代码行数:18,代码来源:SystemTokenClientInterceptor.java
示例13: newToken
import org.apache.cxf.headers.Header; //导入依赖的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);
}
}
}
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:17,代码来源:SoapChannel.java
示例14: ETSoapConnection
import org.apache.cxf.headers.Header; //导入依赖的package包/类
/**
* Class constructor, Initializes a new instance of the class.
* @param client The ETClient object
* @param endpoint The endpoint URL
* @param accessToken The access token
* @throws com.exacttarget.fuelsdk.ETSdkException
*/
public ETSoapConnection(ETClient client, String endpoint, String accessToken)
throws ETSdkException
{
this(client, endpoint);
try {
List<Header> headers = new ArrayList<Header>();
accessTokenElement =
soapFactory.createElement(new QName(null, "fueloauth"));
if (accessToken != null) {
setAccessToken(accessToken);
}
headers.add(new Header(new QName(null, "fueloauth"), accessTokenElement));
soapClient.getRequestContext().put(Header.HEADER_LIST, headers);
} catch (SOAPException ex) {
throw new ETSdkException("could not initialize SOAP proxy", ex);
}
}
开发者ID:salesforce-marketingcloud,项目名称:FuelSDK-Java,代码行数:29,代码来源:ETSoapConnection.java
示例15: addRequestingCaisiProviderNo
import org.apache.cxf.headers.Header; //导入依赖的package包/类
private static void addRequestingCaisiProviderNo(SoapMessage message, String providerNo) {
List<Header> headers = message.getHeaders();
if (providerNo != null) {
headers.add(createHeader(REQUESTING_CAISI_PROVIDER_NO_QNAME, REQUESTING_CAISI_PROVIDER_NO_KEY, providerNo));
}
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:8,代码来源:AuthenticationOutWSS4JInterceptorForIntegrator.java
示例16: createHeader
import org.apache.cxf.headers.Header; //导入依赖的package包/类
private static Header createHeader(QName qName, String key, String value) {
Document document = DOMUtils.createDocument();
Element element = document.createElementNS("http://oscarehr.org/caisi", "caisi:" + key);
element.setTextContent(value);
SoapHeader header = new SoapHeader(qName, element);
return (header);
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:10,代码来源:AuthenticationOutWSS4JInterceptorForIntegrator.java
示例17: process
import org.apache.cxf.headers.Header; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
List<?> headerList = (List<?>) exchange.getIn().getHeader(Header.HEADER_LIST);
assertNotNull("We should get the header list.", headerList);
assertEquals("Get a wrong size of header list.", 4, headerList.size());
// we don't need send the soap headers to the client
exchange.getIn().removeHeader(Header.HEADER_LIST);
}
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:WSAddressingTest.java
示例18: createRouteBuilder
import org.apache.cxf.headers.Header; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
// START SNIPPET: payload
from(getRouterEndpointURI()).process(new Processor() {
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
List<Source> elements = payload.getBodySources();
assertNotNull("We should get the elements here", elements);
assertEquals("Get the wrong elements size", 1, elements.size());
Element el = new XmlConverter().toDOMElement(elements.get(0));
elements.set(0, new DOMSource(el));
assertEquals("Get the wrong namespace URI", "http://camel.apache.org/pizza/types",
el.getNamespaceURI());
List<SoapHeader> headers = payload.getHeaders();
assertNotNull("We should get the headers here", headers);
assertEquals("Get the wrong headers size", headers.size(), 1);
assertEquals("Get the wrong namespace URI",
((Element)(headers.get(0).getObject())).getNamespaceURI(),
"http://camel.apache.org/pizza/types");
// alternatively you can also get the SOAP header via the camel header:
headers = exchange.getIn().getHeader(Header.HEADER_LIST, List.class);
assertNotNull("We should get the headers here", headers);
assertEquals("Get the wrong headers size", headers.size(), 1);
assertEquals("Get the wrong namespace URI",
((Element)(headers.get(0).getObject())).getNamespaceURI(),
"http://camel.apache.org/pizza/types");
}
})
.to(getServiceEndpointURI());
// END SNIPPET: payload
}
};
}
开发者ID:HydAu,项目名称:Camel,代码行数:41,代码来源:CxfPayLoadSoapHeaderTest.java
示例19: doTestInOutOfBandHeaderCamelTemplate
import org.apache.cxf.headers.Header; //导入依赖的package包/类
protected void doTestInOutOfBandHeaderCamelTemplate(String producerUri) throws Exception {
// START SNIPPET: sending
Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
final List<Object> params = new ArrayList<Object>();
Me me = new Me();
me.setFirstName("john");
me.setLastName("Doh");
params.add(me);
senderExchange.getIn().setBody(params);
senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "inOutOfBandHeader");
List<Header> headers = buildOutOfBandHeaderList(false);
Map<String, Object> requestContext = new HashMap<String, Object>();
requestContext.put(Header.HEADER_LIST, headers);
senderExchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext);
Exchange exchange = template.send(producerUri, senderExchange);
org.apache.camel.Message out = exchange.getOut();
MessageContentsList result = (MessageContentsList)out.getBody();
Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>)out.getHeader(Client.RESPONSE_CONTEXT));
assertNotNull(responseContext);
assertTrue("Expected the out of band header to propagate but it didn't",
result.get(0) != null && ((Me)result.get(0)).getFirstName().equals("pass"));
}
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:CxfMessageHeadersRelayTest.java
示例20: doTestInOutOutOfBandHeaderCamelTemplate
import org.apache.cxf.headers.Header; //导入依赖的package包/类
public void doTestInOutOutOfBandHeaderCamelTemplate(String producerUri) throws Exception {
// START SNIPPET: sending
Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
final List<Object> params = new ArrayList<Object>();
Me me = new Me();
me.setFirstName("john");
me.setLastName("Doh");
params.add(me);
senderExchange.getIn().setBody(params);
senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "inoutOutOfBandHeader");
List<Header> inHeaders = buildOutOfBandHeaderList(false);
Map<String, Object> requestContext = new HashMap<String, Object>();
requestContext.put(Header.HEADER_LIST, inHeaders);
senderExchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext);
Exchange exchange = template.send(producerUri, senderExchange);
org.apache.camel.Message out = exchange.getOut();
MessageContentsList result = (MessageContentsList)out.getBody();
assertTrue("Expected the out of band header to propagate but it didn't",
result.get(0) != null && ((Me)result.get(0)).getFirstName().equals("pass"));
Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>)out.getHeader(Client.RESPONSE_CONTEXT));
assertNotNull(responseContext);
validateReturnedOutOfBandHeader(responseContext);
}
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:CxfMessageHeadersRelayTest.java
注:本文中的org.apache.cxf.headers.Header类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论