use of org.apache.cxf.headers.Header in project components by Talend.
the class NetSuiteClientService method setLoginHeaders.
/**
* 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);
}
}
}
use of org.apache.cxf.headers.Header in project components by Talend.
the class NetSuiteClientServiceTest method testConnectAndLogin.
/**
* TODO Verify headers (applicationInfo etc.)
*/
@Test
public void testConnectAndLogin() throws Exception {
final NetSuiteCredentials credentials = webServiceMockTestFixture.getCredentials();
final NetSuitePortType port = webServiceMockTestFixture.getPortMock();
SessionResponse sessionResponse = new SessionResponse();
sessionResponse.setStatus(createSuccessStatus());
LoginResponse response = new LoginResponse();
response.setSessionResponse(sessionResponse);
when(port.login(argThat(new AssertMatcher<LoginRequest>() {
@Override
protected void doAssert(LoginRequest target) throws Exception {
assertEquals(credentials.getEmail(), target.getPassport().getEmail());
assertEquals(credentials.getPassword(), target.getPassport().getPassword());
assertEquals(credentials.getRoleId(), target.getPassport().getRole().getInternalId());
assertEquals(credentials.getAccount(), target.getPassport().getAccount());
MessageContext messageContext = MessageContextHolder.get();
assertNotNull(messageContext);
List<Header> headers = (List<Header>) messageContext.get(Header.HEADER_LIST);
assertNotNull(headers);
Header appInfoHeader = NetSuiteWebServiceMockTestFixture.getHeader(headers, new QName(NetSuiteClientServiceImpl.NS_URI_PLATFORM_MESSAGES, "applicationInfo"));
assertNotNull(appInfoHeader);
}
}))).thenReturn(response);
NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
clientService.login();
verify(port, times(1)).login(any(LoginRequest.class));
}
use of org.apache.cxf.headers.Header in project winery by eclipse.
the class Headers method asMap.
public static Map<String, String> asMap(final WebServiceContext ctx) {
Map<String, String> headers = new HashMap<>();
for (Header h : asList(ctx)) {
Element n = (Element) h.getObject();
headers.put(n.getLocalName(), n.getTextContent());
}
return headers;
}
Aggregations