简体   繁体   English

Java SOAP WebService:如何将字符串数组用作 WSDL 方法的输入?

[英]Java SOAP WebService: how can I use as input an array of String for a method on a WSDL?

I'm developing a WebService SOAP in Java 1.6 version (constraint of infrastruct of customer) and I need to develop an operation method that take as input an plain object with a String and an array of String, and return an output (after some elaboration).我正在 Java 1.6 版本中开发 WebService SOAP(客户基础设施的约束),我需要开发一种操作方法,该方法将带有字符串和字符串数组的普通对象作为输入,并返回一个输出(经过一些详细说明) )。 The input object it's made of a String codiceFiscale and the array of String is that field named classificazioni that you see in the code example:它由 String codiceFiscale和 String 数组组成的输入对象是您在代码示例中看到的名为classificazioni 的字段:

I've this situation on WSDL:我在 WSDL 上遇到过这种情况:

<complexType name="VerificaClassiPFInputDTO">
            <sequence>
                <element name="codiceFiscale" nillable="true" type="xsd:string" />
                <element name="classificazioni" type="xsd:string" nillable="true"
                    minOccurs="0" maxOccurs="unbounded" />
            </sequence>
        </complexType>

and this is my INPUT DTO (java side):这是我的 INPUT DTO(java 端):

public class VerificaClassiPFInputDTO implements Serializable {


private static final long serialVersionUID = -3933923831884051815L;

/**
 * Codice Fiscale della PF
 */
private String codiceFiscale = "";
/**
 * Array di classificazioni da processare sul codice fiscale passato
 */
private String[] classificazioni = null;

/**
 * Costruttore default
 */
public VerificaClassiPFInputDTO() {
    super();
}

public String getCodiceFiscale() {
    return codiceFiscale;
}

public void setCodiceFiscale(String codiceFiscale) {
    this.codiceFiscale = codiceFiscale;
}

public String[] getClassificazioni() {
    return classificazioni;
}

public void setClassificazioni(String[] classificazioni) {
    this.classificazioni = classificazioni;
}

that String[] it's my array.那个 String[] 这是我的数组。 When I deploy the WS, in a SOAPUI client, the situation for this method is this当我在 SOAPUI 客户端中部署 WS 时,此方法的情况是这样的

在此处输入图片说明

and for me is correct.对我来说是正确的。 I want "0 on more" String as input in that array, for that field.对于该字段,我希望“0 on more”字符串作为该数组中的输入。 In this case are three String in the array, and the other string codiceFiscale .在这种情况下,数组中有三个 String ,另一个字符串codiceFiscale

Even in IBM RAD Web Service Explorer tool the situation is this:即使在 IBM RAD Web Service Explorer 工具中,情况也是这样:

在此处输入图片说明

so, for me it's ok.所以,对我来说没关系。 But, when I pass more string (in the array) only the last one been processed .但是,当我传递更多字符串(在数组中)时,只有最后一个被处理

在此处输入图片说明

In the code, when I process input, I obtain always an 1 length array of String , with the last one.在代码中,当我处理输入时,我总是获得一个长度为 1 的 String 数组,最后一个。

在此处输入图片说明

So, what's wrong?那么,怎么了? How can I maps that type of input in WSDL, in the DTO etc?如何在 WSDL、DTO 等中映射该类型的输入? Why does this happen?为什么会发生这种情况?

If I switct in the DTO the type如果我在 DTO 中输入类型

from String[] to List<String> classificazioni

don't work that operation, says mismatch type in the format when run, and I try to call method.不执行该操作,运行时显示格式不匹配类型,我尝试调用方法。

Please someone can help me?请有人可以帮助我吗? If I have to change the map in the WSDL, and the DTO accordingly, that's not a problem but how?如果我必须相应地更改 WSDL 和 DTO 中的映射,那不是问题,但如何更改?

What should I put in the WSDL as complextype and consequently in the DTO, in order to have that kind of input?为了获得这种输入,我应该在 WSDL 中放入什么作为complextype并因此放入 DTO 中?

Please help me....I am going crazy :(请帮帮我....我快疯了:(

I think me and my colleagues have solved it.我想我和我的同事已经解决了。 You must write the setClassificazioni method in this way:您必须以这种方式编写setClassificazioni方法:

ADD other two methods添加其他两种方法

public String getClassificazioni(int i){
  return classificazioni[i];
}

public void setClassificazioni(int i, String classificazione){
   this.classificazioni[i] = classificazione;
}

IMPORTANT: It works for arrays of all types, also array having not java primitive type.重要提示:它适用于所有类型的数组,也适用于没有 java 原始类型的数组。 I don't know if it works also with multidimentional array (adapting method).我不知道它是否也适用于多维数组(适应方法)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从使用Spring部署的JAX-WS Web服务WSDL更改自动生成的soap:地址 - How can I change the autogenerated soap:address from a JAX-WS webservice WSDL deployed with Spring 如何在JBoss 7 Java Web服务中更改肥皂地址 - How can I change soap address in a JBoss 7 java webservice 使用Java中的SOAP Web服务,仅使用WSDL - Consume SOAP webservice in java, only WSDL in hand WSDL SOAP Web 服务 Java 客户端的错误 415 - Error 415 for WSDL SOAP Webservice Java client 如何使用String数组中的用户输入来调用其他对象的方法? - How can I use user input in a String array to call a different object's method? 如何使用Java代码或ant-target访问基于https的Web服务提供的远程WSDL? - How can I access the remote WSDL provided by a webservice based on https in java code or ant-target? 如何使Java客户端使用参数调用soap WebService方法? - How do I make a java client to call a soap WebService method with parameters? Java SOAP WebService-如何接受单个输入参数 - Java SOAP WebService - How to accept single input parameter 如何在 Java 的 get 和 return 方法中使用 input(int)? - How can i use input(int) in get and return method in Java? 在java中使用wsdl,username和password调用soap webservice - Calling soap webservice using wsdl, username and password in java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM