首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

求解!关于Java调用WebService的有关问题

2012-03-22 
求解!!!!关于Java调用WebService的问题public class MyWebService {private static String url http://

求解!!!!关于Java调用WebService的问题
public class MyWebService {

private static String url = "http://websrv.qmedia.mobi:8081/services/SysXSWebService?wsdl";
private String soapaction = "http://qumedia.service/";

@SuppressWarnings({ "unchecked", "unchecked" })
public MyWebService() {

String appKey = "qeahkeye3a1974da422f26b";
String machineId = "sansul61";
String customerCouponId = "2011092360";
String storeKey = "123456";

Service service = new Service();

try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
call.setReturnClass(java.lang.String[].class);


call.setOperationName(new QName(soapaction, "doUseCoupon"));

call.addParameter(new QName(soapaction, "appKey"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(soapaction, "machineId"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(soapaction, "customerCouponId"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(soapaction, "storeKey"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);

call.setReturnType(new
QName(soapaction,"doUseCoupon"),Vector.class);
//call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapaction + "doUseCoupon");
  String[] result = (String[]) call.invoke(new Object[]{appKey,machineId,customerCouponId,storeKey});
   
//Vector vector = (Vector) call.invoke(new Object[] { appKey, machineId,
//customerCouponId, storeKey });
for (int i = 0; i < result.length; i++) {
System.out.println(result[i]);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}


[解决办法]

热点排行