【发布时间】:2011-01-21 10:33:29
【问题描述】:
我想用java中的apache轴连接到web服务,我有一些错误的参数,但我不知道是哪个:
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());
}
}
}
网络服务链接:http://www.w3schools.com/webservices/tempconvert.asmx
在 ret 变量中,我收到消息错误。这是因为我在 QName 中有错误的参数吗?
【问题讨论】:
标签: java web-services apache soap axis