62,614
社区成员
发帖
与我相关
我的任务
分享
public static String getService() {
URL url = null;
try {
url=new URL("http://XXX.XXX.XXX.XXX/aaa/services/MailCsService");
} catch (MalformedURLException mue) {
return mue.getMessage();
}
// This is the main SOAP object
Call soapCall = new Call();
soapCall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
soapCall.setTargetObjectURI("MailCsService");
soapCall.setMethodName("getMails");
Vector soapParams = new Vector();
Parameter isbnParam1 = new Parameter("in0", String.class, "0", null);
Parameter isbnParam2 = new Parameter("in1", String.class, "aaa", null);
Parameter isbnParam3 = new Parameter("in2", String.class, "bbbb", null);
soapParams.addElement(isbnParam1);
soapParams.addElement(isbnParam2);
soapParams.addElement(isbnParam3);
soapCall.setParams(soapParams);
System.out.println(1);
try {
// Invoke the remote method on the object
System.out.println(2);
Response soapResponse = null;
soapResponse = soapCall.invoke(url,"getMails");
System.out.println(3);
// Check to see if there is an error, return "N/A"
if (soapResponse.generatedFault()) {
Fault fault = soapResponse.getFault();
System.err.println("Generated fault: ");
System.out.println("Fault Code = " + fault.getFaultCode());
System.out.println("Fault String = " + fault.getFaultString());
String f = fault.getFaultString();
System.out.println("qqq");
return f;
} else {
// read result
System.out.println("2qqq");
Parameter soapResult = soapResponse.getReturnValue ();
// get a string from the result
return soapResult.getValue().toString();
}
} catch (SOAPException se) {
System.out.println("3qqq");
return se.getMessage();
}
}
public static void main(String[] args) throws Exception {
System.out.println(getService());
}