webservice使用JAX方式调用wsdl文件传入值为空
public static void main(String[] args) {
try {
String url="http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
Service service=new Service();
//创建call对象
Call call=(Call) service.createCall();
//传入wsdl地址
call.setTargetEndpointAddress(url);
//WSDL里面描述的接口名称
call.setOperationName(new QName("http://ws.webxml.com.cn/","getMobileCodeInfo"));
//传入参数
call.addParameter("arg0", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
//设置返回值类型
call.setReturnClass(java.lang.String.class);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://WebXml.com.cn/getMobileCodeInfo");
//传入参数
Object[] param= new Object[] {"13625052452",""};
//调用接口
String result=(String) call.invoke(param);
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
}
这是代码,是根据手机号码查询归属地的方法。运行提示:手机号码错误 http://www.webxml.com.cn
分析了一下,可能是因为方法的传入值为空照成的。
有大神可以看一下是哪里出了问题吗?