2010-02-01 106 views
0

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

登錄操作

<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服務瀏覽器。我現在在「操作」窗格中獲取一個表單,其中包含用於指定loginDetails,productList,quantityList和tenantDetails的字段。

所以,我的問題是,因爲loginDetails,productList,quantityList和tenantDetails都是ArrayList對象,如何輸入它們的值?

+0

你的WSDL中「impl:ArrayOf_xsd_anyType」的定義究竟是什麼?我們可以猜測並可能接近它,但如果我們不需要猜測,它會好得多。 – 2010-02-01 12:23:28

+0

我用impl的定義更新了我的問題:ArrayOf_xsd_anyType – Ryan 2010-02-01 12:39:12

+0

我建議您嘗試使用SoapUI(http://www.soapui.org/)測試您的Web服務。它是一個免費的工具,具有非常友好的界面來測試Web服務。從WSDL它會創建一個測試你的服務的請求,你只需要替換「?」與價值... – JuanZe 2010-02-01 12:47:36

回答

0

讓我告訴你一個例子,也許它可以幫助你。

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 + "]"; 
    } 
} 

和Web服務

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爲您生成的請求時,你會得到這樣的事情

enter image description here

和結果(在你的服務器日誌中)

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

但是,當然,你要發送的這些東西一個數組,所以......

enter image description here

,瞧,結果將是

[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]] 

疑難雜症? :-)

令人難以置信的是,我們無法找到任何答案。

相關問題