Calling webservices from Java actions

I’m having difficulty calling an external webservice from a Java action which seems to be down to the Mendix application server environment. The code I have runs successfully when run as an independent JUnit test or when running XAS in debug mode in Eclipse. However when running from the modeller or from the command line I run into problems with parsing the SOAP response. I can see correct data is being returned by adding the VM argument but in the code I am being returned an empty object with all the fields set to their default values. Clearly the problem is environmental and I guess something to do with which classes the application server is using to parse the SOAP response.
4 answers

I suggest you use the Mendix webservices module (com.mendix.modules.webservices.WebserviceModule). It offers two public methods:

public static InputStream call(String location, String soapAction, String soapRequestMessage)


public static InputStream call(String location, String soapAction, InputStream soapRequestMessage)

which should be sufficient for your needs. If you need to use your own webservice lib you might want to checkout what Arjen suggested, it could be a jar loading issue with one of our own java libraries.


In respose to Achiel's comment: service = create(new URL("xxxx"), new QName("yyyy", "ReportExecutionService"));
ReportExecutionServiceSoap proxy = service.getPort(ReportExecutionServiceSoap.class);
((, “username”);
((, “password”);
ExecutionInfo executionInfo = proxy.loadReport(“ReportName”, null);

ReportExecutionServiceSoap and ExecutionInfo are both classes generated by jax-ws, it is ExecutionInfo which is coming back unexpectedly empty when running via the Mendix modeller.


I agree with Arjen that it is likely a library problem. Currently in userlib I have jaxb-impl-2.1.7.jar, jaxws-rt-2.1.4.jar, stax-ex-1.2.jar and streambuffer-0.7.jar. We are running java 1.6.10 which already contains the jaxb API.

If possible I would rather use these webservice libraries as it makes the code more standard and easier for other Java developers to maintain. I’ll certainly investigate using the Mendix webservice module though, it may help us narrow down what the actual problem is.


The solution for this problem was to put all the custom Java classes which were not in the xxx.actions package into a jar file in the userlib directory. Clearly the problem is down to classloading, but quite what the exact nature of it is remains a mystery.