当前位置: 代码迷 >> Java相关 >> 求解!关于Java调用WebService的有关问题
  详细解决方案

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

热度:1662   发布时间:2013-02-25 21:48:02.0
求解!!!!关于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());
}


------解决方案--------------------------------------------------------
  相关解决方案