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中有錯誤的參數。