如何在axis2 Web服务客户端中发送和接收string []?

时间:2018-10-24 03:54:07

标签: java web-services axis2

在我的Web服务服务器中,我有一个功能:

public static String[] fooStringArray(String[] listInput){
       String[] rs = null;
       //Do something
       return String[];
}

我想在带有axis2的客户端中调用此函数,但不知道如何执行。我尝试了一些方法,但都失败了。这是我的普通字符串代码。

private ServiceClient initClient(String action){
    ServiceClient client = null;
    try {
        ConfigurationContext ctx = ConfigurationContextFactory
                .createConfigurationContextFromFileSystem(null,null);

        client = new ServiceClient(ctx, null);
        Options options = new Options();
        options.setAction(action);
        options.setTo(new EndpointReference("https://service.example.com/services/service?wsdl"));
        options.setProperty(
                org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
                Boolean.FALSE);
        client.setOptions(options);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return client;
}

private String getRSNormalStrng(String data) {
    ServiceClient client = initClient("urn:fooString");
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://service.example.com", "ns1");
    OMElement elem = factory.createOMElement("fooString", ns);
    OMElement childType = factory.createOMElement("stringInput", null);
    childType.setText(data);
    elem.addChild(childType);
    return client.sendReceive(elem).getFirstElement().getText().toString();
}

0 个答案:

没有答案