I'm creating a Spring webapplication (actually a portlet for Liferay), where I have to communicate with a webservice. Our webapplication runs on JBoss 7.1.1. I've done this before without much trouble, the only difference was that in that time the application ran on a Tomcat server.
I've tested the webservice with a soap plugin, and I can conclude that the webservice is running ok.
What did I do:
I created pojo files (DTO's?) from the provided .wsdl file, using maven-jaxb2-plugin. Those classes are generated well. Then I've defined my marshalling beans:
@Configuration
public class WebServiceConfiguration {
@Bean
public Jaxb2Marshaller persoonServiceMarshaller() {
Jaxb2Marshaller m = new Jaxb2Marshaller();
m.setMtomEnabled(true);
m.setContextPath("services");
return m;
}
@Bean
public WebServiceTemplate persoonTemplate(Jaxb2Marshaller persoonServiceMarshaller) {
WebServiceTemplate w = new WebServiceTemplate();
w.setMarshaller(persoonServiceMarshaller);
w.setUnmarshaller(persoonServiceMarshaller);
w.setDefaultUri("my hardcoded webservice location URI...");
return w;
}
Then I wrote a method to test this thing out:
@Autowired
WebServiceTemplate persoonTemplate;
public int getPersonCount(String lastName, String firstName, int birthYear,
int birthMonth, String postalCode) {
System.out.println("Getting PersonCount");
ZoekPersonen zp = new ObjectFactory().createZoekPersonen();
PersoonZoekCriteria criteria = new ObjectFactory()
.createPersoonZoekCriteria();
if (lastName != null && !lastName.equals("")) {
criteria.setNaam(new ObjectFactory().createPersoonDTONaam(lastName));
}
if (firstName != null && !firstName.equals("")) {
criteria.setVoornaam(new ObjectFactory()
.createPersoonDTONaam(firstName));
}
if (birthYear != 0) {
criteria.setGeboorteJaar(new ObjectFactory()
.createPersoonZoekCriteriaGeboorteJaar(birthYear));
}
if(birthYear != 0) {
criteria.setGeboorteMaand(new ObjectFactory()
.createPersoonZoekCriteriaGeboorteMaand(birthMonth));
}
if(postalCode != null && !postalCode.equals("")) {
criteria.setPostCode(new ObjectFactory()
.createPersoonZoekCriteriaPostCode(postalCode));
}
@SuppressWarnings("unchecked")
JAXBElement<ZoekPersonenResponse> jaxBResponse = (JAXBElement<ZoekPersonenResponse>) persoonTemplate
.marshalSendAndReceive(new ObjectFactory()
.createZoekPersonen(zp));
return jaxBResponse.getValue().getReturn().getGevondenPersonen()
.getValue().getPersoonDTO().size();
}
When I test this method, this Exception is thrown:
13:12:54,278 INFO [stdout] (http--0.0.0.0-443-6) 13:12:54,275 ERROR [http--0.0.0.0-443-6][render_portlet_jsp:132] null
13:12:54,279 INFO [stdout] (http--0.0.0.0-443-6) org.springframework.ws.soap.client.SoapFaultClientException: Fault occurred while processing.
13:12:54,281 INFO [stdout] (http--0.0.0.0-443-6) at BLL.PersoonBLL.getPersonCount(PersoonBLL.java:53)
13:12:54,283 INFO [stdout] (http--0.0.0.0-443-6) at controllers.MyController.renderView(MyController.java:44)
13:12:54,284 INFO [stdout] (http--0.0.0.0-443-6) at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
13:12:54,285 INFO [stdout] (http--0.0.0.0-443-6) at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
13:12:54,286 INFO [stdout] (http--0.0.0.0-443-6) at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
13:12:54,290 INFO [stdout] (http--0.0.0.0-443-6) at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
13:12:54,294 INFO [stdout] (http--0.0.0.0-443-6) at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
I'm clueless, I think It has something to do with JBoss, googled it, but did not find useful information.
FYI: My dependencies and Plugin from my Maven POM:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<configuration>
<schemaDirectory>src\main\resources</schemaDirectory>
<schemaIncludes>
<include>PersoonWebService.wsdl</include>
</schemaIncludes>
<generatePackage>services</generatePackage>
<generateDirectory>src\main\java</generateDirectory>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>${spring-ws.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.suite.version}</version>
</dependency>
Spring WS version = 2.1.4-RELEASE Spring suite version = 3.2.4-RELEASE
Upgrading spring versions or JBoss version is sadly no option. This has to run in an existing production environment.
Hints and tips are very welcome!
Fixed this one on my own:
SoapFaultClientException: Exception is thrown by WebService! My request lacked some parameters that where obligated. Even altough the wsdl did not mention them as required.
==> The problem was not JBoss specific, what I first thought. (Sorry for shaming you Jboss, but I still do not like you ;-) ).