2010-02-01 125 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]] 

疑难杂症? :-)

令人难以置信的是,我们无法找到任何答案。

相关问题