Это длинный путь, но я пытаюсь написать клиент веб-службы с Spring-WS.Я получаю NullPointerException
со следующим кодом:
public class WebServiceProcess {
private WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
private CommonsHttpMessageSender messageSender = new CommonsHttpMessageSender();
private SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
private Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
private void init() {
Resource schema = new ClassPathResource("/WEB-INF/mySchema.xsd");
marshaller.setSchema(schema);
marshaller.setContextPaths("list of packages with JAXB classes...");
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);
webServiceTemplate.setMessageSender(messageSender);
}
public TestResponse sendRequest(TestRequest request) {
init();
return response = (TestResponse) webServiceTemplate.marshalSendAndReceive("myEndpointURI", request);
}
}
Трассировка стека:
Exception in thread "main" java.lang.NullPointerException
at com.ibm.ws.webservices.engine.utils.WebServicesParserFactory.setNamespaceAware(WebServicesParserFactory.java:160)
at com.ibm.ws.webservices.engine.utils.XMLUtils.initSAXFactory(XMLUtils.java:437)
at com.ibm.ws.webservices.engine.utils.XMLUtils.getSAXParser(XMLUtils.java:490)
at com.ibm.ws.webservices.engine.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:293)
at com.ibm.ws.webservices.engine.SOAPPart._getSOAPEnvelope(SOAPPart.java:1064)
at com.ibm.ws.webservices.engine.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:628)
at com.ibm.ws.webservices.engine.SOAPPart.getEnvelope(SOAPPart.java:656)
at org.springframework.ws.soap.saaj.support.SaajUtils.getSaajVersion(SaajUtils.java:155)
at org.springframework.ws.soap.saaj.SaajSoapMessage.getSaajVersion(SaajSoapMessage.java:257)
at org.springframework.ws.soap.saaj.SaajSoapMessage.getImplementation(SaajSoapMessage.java:342)
at org.springframework.ws.soap.saaj.SaajSoapMessage.<init>(SaajSoapMessage.java:117)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:184)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:58)
at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:90)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:548)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:496)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:343)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:333)
at com.lmig.processing.WebServiceProcess.sendRequest(WebServiceProcess.java:66)
at com.lmig.processing.TestProcess.main(MainProcess.java:57)
Любая помощь будет оценена .... Я знаю, что у меня нетмного чего можно продолжить.Спасибо.