示例#1
0
  public void doCall(String method, Object value) throws Exception {
    Call call = new Call();
    call.setTargetObjectURI("http://soapinterop.org/");
    call.setMethodName(method);
    call.setEncodingStyleURI(encodingStyleURI);

    Vector params = new Vector();
    params.addElement(new Parameter("in", value.getClass(), value, null));
    call.setParams(params);

    // make the call: note that the action URI is empty because the
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp = call.invoke(url, "");

    // Check the response.
    if (resp.generatedFault()) {
      Fault fault = resp.getFault();
      System.out.println("Ouch, the call failed: ");
      System.out.println("  Fault Code   = " + fault.getFaultCode());
      System.out.println("  Fault String = " + fault.getFaultString());
    } else {
      Parameter result = resp.getReturnValue();
      System.out.println("Call succeeded: ");
      System.out.println("Result = " + result.getValue());
    }
  }
  public void invoke() {
    Call call = new Call();
    call.setTargetObjectURI(d_objectUri);
    call.setMethodName(d_methodName);
    call.setEncodingStyleURI(d_encodingStyleURI);
    call.setParams(d_params);

    try {
      d_resp = call.invoke(s_url, "");
    } catch (SOAPException e) {
      System.err.println("Caught SOAPException (" + e.getFaultCode() + "): " + e.getMessage());
    }

    if (d_resp.generatedFault()) {
      outputFault(d_methodName, d_resp);
    }
  }