我被困在這個問題不知道我做錯了什麼。 我正在使用SOAPWS &當我調用該web服務時,它給出異常&我檢查了WebServiceTemplate對象爲空,但一旦它在構造函數中被初始化。 目前它進入sendNpsReminder操作,它設置爲空。不知道爲什麼。有人可以請幫助。WebServiceTemplate對象爲null後一旦
的pom.xml
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
JavaClass:
public class ManageCustomerService extends WebServiceGatewaySupport {
private static final CDLoggerInterface logger = CDLogger
.getLogger(ManageCustomerService.class);
private WebServiceTemplate manageContactsWSTemplate;
public ManageCustomerService()
{
}
public ManageCustomerService(WebServiceTemplate manageContactsWSTemplateObj) {
this.manageContactsWSTemplate = manageContactsWSTemplateObj;
logger.debug("Constructor Setting the WebServieTemplte "+manageContactsWSTemplate);
}
public SendNPSReminderResponseType sendNpsReminder() {
logger.debug("Calling now with new JOB="+manageContactsWSTemplate);
SendNPSReminderRequestType sendNPSReminderRequest = new SendNPSReminderRequestType();
Contact Contact = new Contact();
Contact.setPhone(new BigInteger("XYZ"));
sendNPSReminderRequest.setCountryCode(ABC);
sendNPSReminderRequest.setContact(Contact);
sendNPSReminderRequest.setCustomerNumber("23239220");
if(manageContactsWSTemplate != null)
{
SendNPSReminderResponseType response = (SendNPSReminderResponseType)manageContactsWSTemplate.marshalSendAndReceive("http://tsi-vip-osbdev.canaldigital.com:7111//GSD_ManageCustomer_v2/ProxyService/Proxy/GSD_ManageCustomer_PS?wsdl", sendNPSReminderRequest, new SoapActionCallback("http://canaldigital.com/tsi/Schema/GSD/GSD_ManageCustomer/v2/GSD_ManageCustomer_SendNPSReminder"));
logger.info("Response for SendNpsReminder is : "+response.getResponseCode());
}
else{
logger.debug("manageContactsWSTemplate is null");
}
return xyz;
}
的applicationContext.xml
<oxm:jaxb2-marshaller id="manageContactMarshaller"
contextPath="packagename" />
<oxm:jaxb2-marshaller id="manageContactUnmarshaller"
contextPath="packagename" />
<bean name="manageContactsWSTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory" />
<property name="defaultUri" value="http://tsi.com:7111/GSD_ManageCustomer_v1?WSDL" />
<property name="marshaller" ref="manageContactMarshaller" />
<property name="unmarshaller" ref="manageContactUnmarshaller" />
</bean>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
</bean>
<bean id="manageContactService" class="com.canaldigital.tsi.managecontacts.serviceprovider.ManageCustomerService">
<constructor-arg ref="manageContactsWSTemplate" />
</bean>
<bean id="CDCommonTasksJob"
class="com.canaldigital.tsi.managecontacts.serviceprovider.ManageCustomerService">
</bean>
<!-- Scheduler -->
<task:scheduled-tasks>
<task:scheduled ref="CDCommonTasksJob" method="sendNpsReminder"
cron="0 0/2 * * * *" />
</task:scheduled-tasks>