Spring WS将对象添加为标题

时间:2018-06-03 21:38:38

标签: soap marshalling soap-client spring-ws

我正在尝试将对象添加到包含登录名,密码和许多其他参数的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.");
    }
}
}

但我总是异常

0 个答案:

没有答案