Hello,
I need to send a SOAP message and receive data back from remote server. I have added some libraries from axis2 (v. 1.2) project. When I try to send a message, program throws:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.apache.commons.httpclient.HttpConnectionManager.getParams()Lorg/apache/commons/httpclient/params/HttpConnectionManagerParams;
I read that there can be a problem in old
commons-httpclient library, but I'm using commons-httpclient-3.0.1.jar, even tried commons-httpclient-3.1-rc1.jar, but had the same problem.
Can you please help me. I can't solve the problem with sending a soap message already for 4 days :(
Here's complete source of my class:
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
public class SoapData{
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(SoapData.class);
private static EndpointReference targetEPR = new EndpointReference("http://remote.server:8080/axis2/services/Service");
public void GetRemoteData(String id, String year) {
try {
OMElement soapMessage = generateSOAP(id, year);
Options options = new Options();
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
logger.debug("done");
OMElement result = sender.sendReceive(soapMessage);
logger.debug("done2");
String response = result.getFirstElement().getText();
logger.debug("done3");
logger.debug("FIRST ELEMENT: " + response);
} catch (Exception e) {
logger.debug(e);
}
}
private OMElement generateSOAP(String fID, String fYear) {
OMFactory omFactory = OMAbstractFactory.getSOAP11Factory();
OMElement envelope = omFactory.createOMElement("soapenv:Envelope", null);
OMNamespace ns = envelope.declareNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv");
OMElement body = omFactory.createOMElement("Body", ns, envelope);
OMElement method = omFactory.createOMElement("getData", null, body);
OMElement dataID = omFactory.createOMElement("farmId", null);
dataID.addChild(omFactory.createOMText(dataID, fID));
method.addChild(dataID);
OMElement dataYear = omFactory.createOMElement("year", null);
dataYear.addChild(omFactory.createOMText(dataYear, fYear));
method.addChild(dataYear);
return envelope;
}
}
It gets to line (
OMElement result = sender.sendReceive(soapMessage);) where it has to communicate with remote server and throws an exception.
Here are libraries I have added to my classpath from axis2: (Maybe I'm missing something?)
activation-1.1.jar
axiom-api-1.2.4.jar
axiom-dom-1.2.4.jar
axiom-impl-1.2.4.jar
axis2-jaxws-1.2.jar
axis2-jaxws-api-1.2.jar
axis2-kernel-1.2.jar
axis2-saaj-1.2.jar
axis2-saaj-api-1.2.jar
backport-util-concurrent-2.2.jar
commons-httpclient-3.0.1.jar
stax-api-1.0.1.jar
wstx-asl-3.2.1.jar
xbean-2.2.0.jar
XmlSchema-1.3.1.jar