f51420fd499b998fb95e86fa0377ced0c39910e9.svn-base 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package UIJ.UIJ03;
  2. import org.apache.soap.util.xml.*;
  3. import org.apache.soap.*;
  4. import org.apache.soap.rpc.*;
  5. import java.io.*;
  6. import java.net.*;
  7. import java.util.Vector;
  8. public class UIJ030051 {
  9. public static String getService(String user) {
  10. URL url = null;
  11. try {
  12. url = new URL(
  13. "http://218.87.96.132/xg56/webservice/mesWaybillService");
  14. } catch (MalformedURLException mue) {
  15. return mue.getMessage();
  16. }
  17. // This is the main SOAP object
  18. Call soapCall = new Call();
  19. // Use SOAP encoding
  20. soapCall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
  21. // This is the remote object we're asking for the price
  22. soapCall.setTargetObjectURI("urn:xmethods-caSynrochnized");
  23. // This is the name of the method on the above object
  24. soapCall.setMethodName("queryIsLock");
  25. // We need to send the ISBN number as an input parameter to the method
  26. Vector soapParams = new Vector();
  27. // name, type, value, encoding style
  28. Parameter isbnParam = new Parameter("userName", String.class, user,
  29. null);
  30. soapParams.addElement(isbnParam);
  31. soapCall.setParams(soapParams);
  32. try {
  33. // Invoke the remote method on the object
  34. Response soapResponse = soapCall.invoke(url, "");
  35. // Check to see if there is an error, return "N/A"
  36. if (soapResponse.generatedFault()) {
  37. Fault fault = soapResponse.getFault();
  38. String f = fault.getFaultString();
  39. return f;
  40. } else {
  41. // read result
  42. Parameter soapResult = soapResponse.getReturnValue();
  43. // get a string from the result
  44. return soapResult.getValue().toString();
  45. }
  46. } catch (SOAPException se) {
  47. return se.getMessage();
  48. }
  49. }
  50. }