0

In my project (Liferay Portlet), im creating a webservice-client. I've defined a webServiceTemplate in my applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">

    <context:annotation-config />
    <context:component-scan base-package="be.icredit.einvoice.service, be.icredit.einvoice.webserviceTest" />


    <oxm:jaxb2-marshaller id="marshaller" contextPath="be.icredit.einvoice.proxy.customerdaoservice"/>
    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
         <property name="marshaller" ref="marshaller" /> 
         <property name="unmarshaller" ref="marshaller" /> 
        <property name="defaultUri"
            value="http://localhost:8081/ws-demo/account-balance-service" />
    </bean>

</beans>

When i execute testFindCustomer method in my CustomerClient.java, I get a nullpointerexception on the webServiceTemplate.

public class CustomerClient extends WebServiceGatewaySupport {

        @Autowired
        private WebServiceTemplate webServiceTemplate;

        private Log log = LogFactory.getLog(CustomerClient.class);

        public CustomerClient()
        {


        }
        public void testFindCustomer()
        {
            Find findCustomer = new Find();
            findCustomer.setFilter(new CustomerFilter());

            System.out.println(webServiceTemplate.getDefaultUri());
            FindResponse response = (FindResponse) webServiceTemplate.marshalSendAndReceive(findCustomer);

            ArrayList<Customer> list = (ArrayList) response.getReturn();        
            for(Customer c : list)
            {
                log.info("found");
            }

        }

This looks pretty basic, I have no clue what I'm doing wrong. The CustomerClient class is located in the be.icredit.einvoice.webserviceTest package.

Nullpointerexceptions happens on the System.out.println(webServiceTemplate.getDefaultUri()); line.

Kornelito Benito
  • 1,067
  • 1
  • 17
  • 38

0 Answers0