Как отправить и получить строку [] в клиенте веб-службы axis2? - PullRequest
0 голосов
/ 24 октября 2018

На моем сервере веб-сервиса у меня есть функция:

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();
}
...