I have a WSDL file for a web service which i want to test. Im using the Web Services Explorer in Eclipse to test the webservice. The webservice defines a login operation,containing a loginRequest message. The definitions are as shown below.
Login Operation
<wsdl:operation name="login" parameterOrder="in0">
<wsdl:input message="impl:loginRequest" name="loginRequest"/>
</wsdl:operation>
loginRequest Message
<wsdl:message name="loginRequest">
<wsdl:part name="in0" type="tns1:CompiereBean"/>
</wsdl:message>
CompiereBean object
<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"/>
开发者_如何学Python </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>
Now, to test the webservice, i right click on the WSDL file->Web Services->Test with Web Services Explorer. I now get a form in the Actions pane,with fields for specifying loginDetails,productList,quantityList and tenantDetails.
So, my question is since loginDetails,productList,quantityList and tenantDetails are all ArrayList objects, how to input their values ?
Let me show you an example and maybe it can help you.
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 + "]";
}
}
and the web service
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));
}
}
then if you use soapUI to generate the request for you, you'll get something like this
and the result will be (in your server logs)
[Thing [name=aeoliam venit, date=Sun Sep 28 22:49:45 BRT 2008, longg=10]]
but, of course, you want to send an array of these things, so...
and voila, the result will be
[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]]
gotcha? :-)
it´s incredible that we just can't find anywhere this answer.
精彩评论