Hi, I'm developing a client to communicate with CMDBuild web services according to the supplied java example.
I generated the sources from a wsdl file using Axis2 1.6.2. Also installed rampart 1.6.2
My client test code is below.
The problem is that I'm getting the error:
Exception in thread "main" java.lang.ClassCastException: org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory cannot be cast to org.apache.axiom.om.impl.builder.OMFactoryEx
on the line
configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:/Apache_Software_Foundation/axis2-1.6.2/repository", null);
Can anyone help me?
Thanks!
package cmdbuild.ws.client;
import java.io.FileNotFoundException;
import javax.xml.stream.XMLStreamException;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
import org.cmdbuild.services.soap.Card;
import org.cmdbuild.services.soap.CardList;
import org.cmdbuild.services.soap.GetCardList;
import org.cmdbuild.services.soap.GetCardListResponse;
import org.cmdbuild.services.soap.impl.GetCardListImpl;
public class TestClient {
public void test() {
try {
ConfigurationContext configContext = null;
configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem("C:/Apache_Software_Foundation/axis2-1.6.2/repository", null);
WebservicesImplServiceStub stub = new WebservicesImplServiceStub(configContext);
StAXOMBuilder builder = new StAXOMBuilder("C:/Apache_Software_Foundation/axis2-1.6.2/repository/conf/policy.xml");
Options options = stub._getServiceClient().getOptions();
options.setUserName("admin");
options.setPassword("admin");
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, PolicyEngine.getPolicy(builder.getDocumentElement()));
GetCardList list = new GetCardListImpl(null);
list.setClassName("Computer");
GetCardListResponse response = (GetCardListResponse) stub.getCardList(list);
CardList card = response.getReturn();
Card[] cardArr = card.getCardsArray();
for (int i = 0; i < cardArr.length; i++) {
System.out.println(cardArr[i].getId());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args)
{
TestClient tc = new TestClient();
tc.test();
}
}