public class AxisTest {
private static Log log = LogFactory.getLog(AxisTest.class);
protected Object process(String operation, String paramter) throws AxisFault {
Object result = null;
EndpointReference ref = new EndpointReference(url);
Options options = new Options();
options.setTo(ref);
options.setTimeOutInMilliSeconds(60 * 1000);
try {
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace ns = fac.createOMNamespace(nameSpace, "myService");
OMElement method = fac.createOMElement(operation, ns);
if (null != paramter)
method.setText(paramter);
OMElement resp = sender.sendReceive(method).getFirstElement();
String serialize = resp.getText();
log.debug(serialize);
result = decode(serialize);
} catch (AxisFault e) {
log.error("", e);
throw e;
}
return result;
}
public static void main(String[] args) {
}
}
需要的jar
axiom-api-1.2.7.jar
axiom-dom-1.2.7.jar
axiom-impl-1.2.7.jar
axis2-kernel-1.4.jar
backport-util-concurrent-3.1.jar
neethi-2.0.4.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.2.jar
取结果
OMElement resp = sender.sendReceive(method).getFirstElement();
取<return>
OMElement resp = sender.sendReceive(method).getFirstChildWithName(new QName("return"));