Dear all,
I am using CMDBuild version 2.2.0 as an IT asset management tool and I am trying to integrate it with an external tool which will feed CMDBuild with IT assets through webservice API calls. However, after a few days of investigation I am still facing some problems with the implementation of a Java client. Through SOAP UI everything works as expected but when I am trying to call the webservice through Java client I get the following error:
org.apache.axis2.AxisFault: The given SOAPAction http://soap.services.cmdbuild.org/Webservices/getCardList does not match an operation.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at gr.pcomp.cmdb.CmdbuildServiceStub.getCardList(CmdbuildServiceStub.java:569)
at gr.pcomp.cmdb.test.CMDBuildClientTest.main(CMDBuildClientTest.java:67)
Searching the forum I found that I should try the following options to the service client:
stub._getServiceClient().getOptions().setProperty(org.apache.axis2.Constants.Configuration.DISABLE_SOAP_ACTION, true);
However, when I add the above option another error occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/james/mime4j/MimeException
at org.apache.axiom.attachments.Attachments.<init>(Attachments.java:93)
at org.apache.axis2.builder.BuilderUtil.createAttachments(BuilderUtil.java:592)
at org.apache.axis2.builder.BuilderUtil.createAttachmentsMap(BuilderUtil.java:543)
at org.apache.axis2.builder.MIMEBuilder.processDocument(MIMEBuilder.java:39)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:179)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at gr.pcomp.cmdb.CmdbuildServiceStub.getCardList(CmdbuildServiceStub.java:569)
at gr.pcomp.cmdb.test.CMDBuildClientTest.main(CMDBuildClientTest.java:67)
Caused by: java.lang.ClassNotFoundException: org.apache.james.mime4j.MimeException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 14 more
The skeleton of the Java client follows:
public class CMDBuildClientTest {
public static void main(String[] args) {
try {
ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("WebContent/WEB-INF", null);
// Instance the CmdbuildServiceStub
CmdbuildServiceStub stub = new CmdbuildServiceStub(configContext);
ServiceClient client = new ServiceClient();
client = stub._getServiceClient();
client.engageModule("rampart");
// Set the authentication credentials
Options options = stub._getServiceClient().getOptions();
options.setUserName("admin");
options.setPassword("admin");
StAXOMBuilder builder = new StAXOMBuilder("WebContent/WEB-INF/conf/policy2.xml");
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, PolicyEngine.getPolicy(builder.getDocumentElement()));
// System.out.println(builder.getDocumentElement().toStringWithConsume());
System.out.println("[INFO] Policy loaded successfully!");
// ~~~~~~ Do not put "action" into the HTTP header ~~~~~~ //
// stub._getServiceClient().getOptions().setProperty(org.apache.axis2.Constants.Configuration.DISABLE_SOAP_ACTION, true);
// ~~~~~~ GetCardList ~~~~~~ //
GetCardList cardList = new GetCardList();
cardList.setClassName("Computer");
GetCardListE cardListE = new GetCardListE();
cardListE.setGetCardList(cardList);
GetCardListResponseE response = stub.getCardList(cardListE);
response.getGetCardListResponse();
System.out.println(response.getGetCardListResponse().get_return());
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException re) {
re.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XMLStreamException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
In order to generate the stub code for the client I am using Axis2-1.6.2 and Apache Rampart-1.6.2
Has anyone faced the same problems? Please, any hints are more than welcome!
Thanks,
Vangelis