簡體   English   中英

在Eclipse Web Services Explorer中測試WSDL

[英]Testing a WSDL in Eclipse Web Services Explorer

我有一個要測試的Web服務的WSDL文件。 我使用Eclipse中的Web服務資源管理器來測試Web服務。 Web服務定義了一個登錄操作,其中包含一個loginRequest消息。 定義如下所示。

登錄操作

  <wsdl:operation name="login" parameterOrder="in0">

     <wsdl:input message="impl:loginRequest" name="loginRequest"/>

  </wsdl:operation>

loginRequest消息

<wsdl:message name="loginRequest">

      <wsdl:part name="in0" type="tns1:CompiereBean"/>

</wsdl:message>

CompiereBean對象

<complexType name="CompiereBean">
    <sequence>
     <element name="loginDetails" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
     <element name="productList" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
     <element name="quantityList" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
     <element name="tenantDetails" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
    </sequence>
</complexType>

ArrayOf_xsd_anyType

<complexType name="ArrayOf_xsd_anyType">

<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:anyType[]"/>
</restriction>
</complexContent>

</complexType>

現在,要測試Web服務,我右鍵單擊WSDL文件-> Web服務->使用Web服務資源管理器進行測試。 現在,我在“操作”窗格中獲得一個表單,其中包含用於指定loginDetails,productList,quantityList和tenantDetails的字段。

那么,我的問題是由於loginDetails,productList,quantityList和tenantDetails都是ArrayList對象,如何輸入它們的值?

讓我向您展示一個示例,也許它可以為您提供幫助。

package mypackage;

import java.io.Serializable;
import java.util.Date;

public class Thing implements Serializable{

    private static final long serialVersionUID = 4205832525113691806L;
    private String name;
    private Date date;
    private Long longg;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Date getDate() {
        return date;
    }
    public void setDate(Date date) {
        this.date = date;
    }
    public Long getLongg() {
        return longg;
    }
    public void setLongg(Long longg) {
        this.longg = longg;
    }
    @Override
    public String toString() {
        return "Thing [name=" + name + ", date=" + date + ", longg=" + longg + "]";
    }
}

和網絡服務

package mypackage;

import java.util.Arrays;

import javax.ejb.Stateless;
import javax.jws.WebService;

@WebService
@Stateless
public class WS {   
    public void doSomething(Thing[] things){
        System.out.println(Arrays.asList(things));
    }
}

然后,如果您使用soapUI為您生成請求,您將獲得類似以下內容的信息

在此處輸入圖片說明

結果將是(在您的服務器日志中)

[Thing [name=aeoliam venit, date=Sun Sep 28 22:49:45 BRT 2008, longg=10]]

但是,當然,您想發送這些東西的數組,所以...

在此處輸入圖片說明

和瞧,結果將是

[Thing [name=aeoliam venit, date=Sun Sep 28 22:49:45 BRT 2008, longg=10], Thing [name=aeoliam venit, date=Sun Sep 28 22:49:45 BRT 2008, longg=10]]

知道嗎? :-)

令人難以置信的是,我們在任何地方都找不到這個答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM