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

发布于 2024-11-26 11:48:12 字数 661 浏览 0 评论 0原文

这是我第一次编写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,我确信这只是几个方法调用即可;调用.setProperty。请指教

This is my first time writing a web service client, it's funny, I have already written a webservice;)

Anyways, I am using axis to invoke the WS by following code

  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 + "'");

My Service returns a HashMap and has three input parameters apuId,providerId,notes
I am not sure how to send these parameters to the WS, I am sure it's just few method calls away ex; call.setProperty. Please advise

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神也荒唐 2024-12-03 11:48:12

好的,
这就是答案,它还没有完全起作用,因为 Axis 似乎不支持 hashmap 作为 Web 服务响应。

    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 + "'");

Okay,
this is the answer, it does not completely work yet because Axis does not seem to be supporting hashmap as webservice response.

    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 + "'");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文