Мне нужно отправить токены доступа и местоположения, чтобы сделать успешные вызовы SOAP запроса. Мой код указан ниже:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class BrinkClientAuthentication {
@XmlElement
private String accessToken;
@XmlElement
private String locationToken;
public BrinkClientAuthentication() {
}
public BrinkClientAuthentication(String AccessToken, String LocationToken) {
this.accessToken = AccessToken;
this.locationToken = LocationToken;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getLocationToken() {
return locationToken;
}
public void setLocationToken(String locationToken) {
this.locationToken = locationToken;
}
}
public class BrinkClientSecurityHeader implements WebServiceMessageCallback {
private BrinkClientAuthentication authentication;
public BrinkClientSecurityHeader(BrinkClientAuthentication authentication) {
this.authentication = authentication;
}
@Override
public void doWithMessage(WebServiceMessage message) throws IOException {
SoapHeader soapHeader = ((SoapMessage) message).getSoapHeader();
try {
JAXBContext context = JAXBContext.newInstance(BrinkClientAuthentication.class);
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(authentication, soapHeader.getResult());
} catch (JAXBException e) {
throw new IOException("error while marshalling authentication.");
}
}
}
private BrinkClientSecurityHeader getBrinkClientSecurityHeader() {
if (brinkClientSecurityHeader == null) {
return new BrinkClientSecurityHeader(new BrinkClientAuthentication("zxzxzxzx", "cvcvcvcvcv"));
} else {
return brinkClientSecurityHeader;
}
}
Тогда я сделаю звонок:
protected Object sendRequest(WebServiceTemplate webServiceTemplate, Object request, Class<?> expectedResponseType) throws BrinkIntegrationException {
Object response = webServiceTemplate.marshalSendAndReceive(request, getBrinkClientSecurityHeader());
if (response != null && response.getClass() == expectedResponseType) {
return response;
}
throw new BrinkIntegrationException("Something");
}
Я получил ошибку, указанную ниже:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.xml.security.utils.I18n.init(Ljava/util/ResourceBundle;)V
Это потому что заголовок указан неверно или не связан с запросом вызова из кода?