2
我想连接到在Java Apache Axis的Web服务,我有一些错误的参数,但我不知道是哪个:如何调用轴阿帕奇客户端在Java中
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
public class Test_Web_Service
{
public static void main(String [] args) throws Exception {
try {
String endpoint = "http://www.w3schools.com/webservices/tempconvert.asmx";
Service service = new Service();
Call call= (Call) service.createCall();
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://tempuri.org/CelsiusToFahrenheit");
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://tempuri.org/CelsiusToFahrenheit","CelsiusToFahrenheit"));
String ret = (String) call.invoke(new Object[] {"20"});
System.out.println("Sent '20', got '" + ret + "'");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}
Web服务的链接: http://www.w3schools.com/webservices/tempconvert.asmx
在ret变量中,我收到错误消息。这是因为我在QName中有错误的参数。