我正在尝试将对象添加到包含登录名,密码和许多其他参数的soap标头中,我这样做:
public class SecurityHeader implements WebServiceMessageCallback {
private MyObject myObject;
public SecurityHeader(MyObject myObject) {
this.myObject = myObject;
}
@Override
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
SoapHeader soapHeader = ((SoapMessage)message).getSoapHeader();
try {
JAXBContext context = JAXBContext.newInstance(MyObject.class);
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(authentication, soapHeader.getResult());
} catch (JAXBException e) {
throw new IOException("error while marshalling the header.");
}
}
}
但我总是异常