Axis Web服务客户端中的多个参数

时间:2011-07-26 08:17:55

标签: java web-services axis

这是我第一次编写Web服务客户端,这很有趣,我已经编写了一个Web服务;)

无论如何,我使用axis来通过代码

来调用WS
  String endpoint =
            "http://localhost:8080/SpeechServices/SpeechWebService/SpeechWebService";

    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(endpoint));
    call.setOperationName(new QName("http://ws.ecw.com/", "parseNotes"));
    HashMap ret = (HashMap) call.invoke(new Object[]{"", "", ""});
    System.out.println("Sent 'Hello!', got '" + ret + "'");

我的服务返回一个HashMap并有三个输入参数apuId,providerId,notes 我不确定如何将这些参数发送到WS,我相信它只是前几个方法调用; call.setProperty。请指教

1 个答案:

答案 0 :(得分:0)

好, 这是答案,它还没有完全发挥作用,因为Axis似乎不支持hashmap作为webservice响应。

    String endpoint =
            "http://localhost:8080/eCWServices/StructSpeech/StructSpeech";
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(endpoint));
    call.setOperationName(new QName("http://ejb.ecw.com/", "parseNotes"));
    call.addParameter("notes", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN);
    call.addParameter("apuId", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN);
    call.addParameter("providerId", org.apache.axis.Constants.XSD_STRING, ParameterMode.IN);
    call.setReturnType(XMLType.SOAP_MAP);
    HashMap  ret = (HashMap) call.invoke(new Object[]{"","",""});
    System.out.println("Sent 'Hello!', got '" + ret + "'");